2

Is there any way to define multiple sinks in the XML config for serilog that will allow the outputTemplate to change based on the level of log?

I currently have:

    <add key="serilog:minimum-level" value="Verbose" />
    <add key="serilog:write-to:ColoredConsole" />
    <add key="serilog:write-to:RollingFile.pathFormat" value="C:\Logs\AdapterService-{Date}.txt" />
    <add key="serilog:write-to:RollingFile.retainedFileCountLimit" value="10" />
    <add key="serilog:write-to:RollingFile.outputTemplate" value="[{Timestamp:G}] [{Level}] [{SourceContext:l}] {Message}{NewLine:l}{Exception:l}" />

However would like the Debug level logs to not include the SourceContext string as in:

    <add key="serilog:write-to:RollingFile.outputTemplate" value="[{Timestamp:G}] [{Level}] {Message}{NewLine:l}{Exception:l}" />

I am aware you can set the restrictedToMinimumLevel: LogEventLevel.Verbose but I am unsure how to do this in the XML.

Matthew North
  • 553
  • 5
  • 20
  • Does this answer your question? [Serilog - multiple log files](https://stackoverflow.com/questions/28292601/serilog-multiple-log-files) – Michael Freidgeim Aug 21 '23 at 13:40

0 Answers0