serilog-settings-configuration icon indicating copy to clipboard operation
serilog-settings-configuration copied to clipboard

Configuring Console with theme overrides ExpressionTemplate

Open mpiliszcz opened this issue 2 years ago • 1 comments

  "Serilog": {
    "Using": [ "Serilog.Sinks.Console" ],
    "MinimumLevel": {
      "Default": "Information",
      "Override": {
        "Microsoft": "Information",
        "System": "Information"
      }
    },
    "WriteTo": [
      {
        "Name": "Console",
        "Args": {
          "formatter": {
            "type": "Serilog.Templates.ExpressionTemplate, Serilog.Expressions",
            "template": "[{@t:HH:mm:ss}{#if CorrelationId is not null} {Substring(CorrelationId, 0,5)}{#end} {@l:u3}] {#if SourceContext is not null}{SourceContext}{#end}{@m}\n{@x}"
          }//,
          //"theme": "Serilog.Sinks.SystemConsole.Themes.AnsiConsoleTheme::Literate, Serilog.Sinks.Console"
        }
      }
    ],
    "Enrich": [ "WithCorrelationId" ]
  },

If I remove commented out theme definition, the formatter will no longer be used, only theme will be finally configured. We can't have both.

mpiliszcz avatar Feb 14 '23 09:02 mpiliszcz