【发布时间】:2017-09-19 08:07:39
【问题描述】:
我正在尝试与使用 SerilogWeb.Classic.WebApi 一样:
app.Use(async (owinContext, next) =>
{
using (Serilog.Context.LogContext.PushProperty("HttpRequestId", Guid.NewGuid()))
{
await next();
}
});
还有这个模板
{Timestamp:yyyy-MM-dd HH:mm:ss.ffffff zzz} [{Level:u3}] {HttpRequestId}: {SourceContext}: {Message} {Scope}{NewLine}{Exception}
但是HtpRequestId 在日志中总是空的:
2017-09-18 23:26:13.056013 +01:00 [WRN] : <SourceContext>: <message>
我做错了什么?
【问题讨论】:
标签: asp.net-web-api owin serilog owin-middleware