I will consider this as a question like "How to use Serilog.Extras.MSOwin?" and given that this is currently a fairly small library answer.
This reflects the current library (1.4.102) and is subject to change in the future.
Serilog.Extras.MSOwin : Microsoft.Owin.Logging.ILoggerFactory, OWIN Serilog ( OWIN ) Guid (RequestId) -, .
:
IAppBuilder app = ...;
Serilog.ILogger logger = ...'
app.SetLoggerFactory( new Serilog.Extras.MSOwin.LoggerFactory( logger ) );
OWIN:
IAppBuilder app = ...;
app.UseSerilogRequestContext("RequestId");
, , , .
LogContext Enrich.FromLogContext() , . ,
const string DefaultOutputTemplate =
"{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} ({RequestId}) {Message}{NewLine}{Exception}";
ILogger logger =
new LoggerConfiguration().Enrich.FromLogContext()
.WriteTo
.RollingFile(
"log.txt",
outputTemplate: DefaultOutputTemplate)
.CreateLogger();