Meghana M

Meghana M

  • 1.6k
  • 175
  • 23.7k

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)