Serilog请求记录到Application Insights的日志记录为跟踪

时间:2020-02-04 16:36:18

标签: asp.net asp.net-core serilog

我的主代码中有以下代码

Log.Logger = new LoggerConfiguration()
        .MinimumLevel.Debug()
        .MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
        .MinimumLevel.Override("System", LogEventLevel.Warning)
        .MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Warning)
        .Enrich.FromLogContext()
        .WriteTo.ApplicationInsights(
        configuration["ApplicationInsights:InstrumentationKey"],
              new CustomConverter())
        .CreateLogger();

在我的.UseSerilog();方法中使用CreateHostBuilder

然后在我的Configure

app.UseSerilogRequestLogging();

日志已到达应用程序见解,但Requests被记录为Traces

我认为这是由于app.UseSerilogRequestLogging();不了解App Insights而导致的,它只是触发了一个简单的日志,而App Insights不知道其请求跟踪日志,因此它只是将其记录为{ {1}}

如何使Trace生成的日志在UseSerilogRequestLogging中作为Request记录?

0 个答案:

没有答案