【发布时间】:2017-01-10 00:17:38
【问题描述】:
如何启用 DbCommand 原始 SQL 查询的日志记录?
我已将以下代码添加到我的 Startup.cs 文件中,但没有看到来自 Entity Framework Core 的任何日志条目。
void ConfigureServices(IServiceCollection services)
{
services.AddLogging();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug(LogLevel.Debug);
}
我期待看到这样的东西:
Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilder...
SELECT [t].[Id], [t].[DateCreated], [t].[Name], [t].[UserName]
FROM [Trips] AS [t]
【问题讨论】:
标签: c# entity-framework