© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
173 replies
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"
        }
      }
    ]
  }
}
{
  "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"
        }
      }
    ]
  }
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

❔ Serilog: how to write a file for single level
C#CC# / help
3y ago
❔ Serilog.Settings.Configuration file sink not writing to file?
C#CC# / help
3y ago
❔ Serilog Logs Scrambled from Multithreading
C#CC# / help
3y ago
Write to file not working (StreamWriter)
C#CC# / help
4y ago