serilog-sinks-eventlog
serilog-sinks-eventlog copied to clipboard
Do not throw PlatformNotSupportedException
The PlatformNotSupportedException
is problematic when the EventLog sink is configured through Serilog.Settings.Configuration, where it's impossible to conditionally enable on Windows and disable on other platforms.
Real scenario: the production app will run on Windows and the appsettings configuration looks like this (using TOML instead of JSON):
[Serilog.WriteTo.EventLogSink]
Name = 'EventLog'
Args = { source = 'MyApplication', manageEventSource = true, restrictedToMinimumLevel = 'Warning' }
When developing on Linux or macOS, it's impossible to remove the EventLog configuration so it's better for this sink to be ignored since EventLog doesn't exist on these platforms anyway.
Note: this is exactly how the Notepad sink works and it's a good solution.