serilog / serilog-sinks-eventlog

A Serilog sink that writes events to the Windows Event Log
Apache License 2.0
50 stars 29 forks source link

Eventviwer sink does not work with appsettings.json #33

Open yangxinyun opened 5 years ago

yangxinyun commented 5 years ago

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"
    }
  }
}
ColinM9991 commented 4 years ago

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"
        }
      }
    ]
  }