Meghana M

Meghana M

  • 1.4k
  • 175
  • 17.6k

how to Create a separate class and interface for Serilog to customize

Apr 21 2023 10:16 AM

Below is the code i'm using in program.cs 

var configuration = new ConfigurationBuilder()
  .AddJsonFile("appsettings.json")
  .Build();

Log.Logger = new LoggerConfiguration()
    .ReadFrom.Configuration(configuration)
    .CreateLogger();

 

appsettings.json-

"Serilog": {
    "Using": ["Serilog.Sinks.File"],
    "MinimumLevel": {
      "Default": "Information"
     }
    },
    "WriteTo": [
      {
        "Name": "File",
        "Args": {
          "path": "D\log.txt",
          "rollingInterval": "Day",
          "outputTemplate": "{Timestamp:MM/dd/yyyy}"
        }

 


Answers (4)