我的主代码中有以下代码
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
记录?