0

Microsoft.Extensions.Logging Trace vs Serilog Verbose

the workaround: https://github.com/Su-s/serilogworkaround

this is the configuration in my appsettings.json

 "WriteTo": [
  {
    "Name": "Console",
    "Args": {
      "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [correlationId: {CorrelationId} machineName:{MachineName} environmentName:{EnvironmentName} environmentUserName:{EnvironmentUserName} clientIp:{ClientIp} clientAgent:{ClientAgent} processId:{ProcessId} processName:{ProcessName} memory:{MemoryUsage} level:{Level: u3}] ({SourceContext}) {Message} {NewLine} {Exception} {Properties:j}{NewLine}",
      "theme": "Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme::Literate, Serilog.Sinks.Console",
      "restrictedToMinimumLevel": "Information"
    }
  },
  {
    "Name": "File",
    "Args": {
      "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [correlationId: {CorrelationId} machineName:{MachineName} environmentName:{EnvironmentName} environmentUserName:{EnvironmentUserName} clientIp:{ClientIp} clientAgent:{ClientAgent} processId:{ProcessId} processName:{ProcessName} memory:{MemoryUsage} level:{Level: u3}] ({SourceContext}) {Message} {NewLine} {Exception} {Properties:j}{NewLine}",
      "path": "%localappdata%\\weabb.log",
      "rollingInterval": "Day",
      "restrictedToMinimumLevel": "Verbose"
    }
  },
  {
    "Name": "Seq",
    "Args": {
      "serverUrl": "http://localhost:5341",
      "apiKey": "none",
      "restrictedToMinimumLevel": "Information"
    }
  }
],

the logger config in startup

 Log.Logger = new LoggerConfiguration()
              .MinimumLevel.Verbose()
              .Destructure.ByTransforming<UserIdentity>(u => new { u.Id, u.UserName })
              .CreateBootstrapLogger();

here, I only have to log the verbose details inside file log. and the information level log in seq and console.

i think the issue in serilogs are similar to this, but this had happened before 7 years. https://github.com/serilog/serilog-extensions-logging/issues/57

help me please.check the comment. https://github.com/serilog/serilog-extensions-logging/issues/57#issuecomment-1578293716

11738472
  • 184
  • 3
  • 22

0 Answers0