Anyone using Serilog.Extras.MSOwin

I was wondering if anyone saw a demon / example using the Serilog.Extras.MSOwin package with a web api project or an example / tutorial on using Serilog with a web api project.

Any help really appreciated, Jim

+4
source share
2 answers

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();
+4

Serilog.Extras.MSOwin SerilogWeb.Owin ( .)

0

All Articles