C#C
C#3y ago
PontiacGTX

✅ Serilog does not write logs to file

I have tried to configure it on the appsettings to write file but it doesnt
{
  "Serilog": {
    "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ],
    "MinimumLevel": {
      "Default": "Debug",
      "Microsoft": "Information",
      "System": "Information"
    },
    "Enrich": [ "FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId" ],
    "WriteTo": [
      {
        "Name": "Console",
        "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] [{SourceContext}] [{EventId}] {Message}{NewLine}{Exception}"
      },
      {

        "Name": "File",
        "Args": {

          "pathFormat": "\\Employeeslog-{Date}.txt",
          "rollOnFileSizeLimit": true,
          "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] [{SourceContext}] [{EventId}] {Message}{NewLine}{Exception}",
          "formatter": "Serilog.Formatting.Json.JsonFormatter",
          "rollingInterval": "Day"
        }
      }
    ]
  }
}
Was this page helpful?