serilog-sinks-eventlog icon indicating copy to clipboard operation
serilog-sinks-eventlog copied to clipboard

Eventviwer sink does not work with appsettings.json

Open yangxinyun opened this issue 5 years ago • 1 comments

Used following content in my appsetting.json , and no log can be found from the eventviwer. In the meanwhile, tried c# api to configure it, and it worked.

{
  "Serilog": {
    "Using": [ "Serilog.Sinks.EventLog"],
    "MinimumLevel": "Debug",
    "WriteTo": [
      {"Name": "EventLog","Args": { "manageEventSource": true }}
    ],
    "Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId", "WithApplicationName", "WithProcessId" ],
    "Properties": {
      "Application": "Sample App"
    }
  }
}

yangxinyun avatar Jun 04 '19 13:06 yangxinyun

Your WriteTo:Name property is invalid

It should be

  "Serilog": {
    "Using": [ "Serilog.Sinks.EventLog" ],
    "MinimumLevel": {
      "Default": "Debug"
    },
    "WriteTo": [
      {
        "Name": "EventLog",
        "Args": {
          "source": "Source",
          "logName": "Log Name"
        }
      }
    ]
  }

ColinM9991 avatar Nov 13 '19 14:11 ColinM9991