.netasp.net-coreloggingevent-log

ILoggingBuilder AddEventLog Linux compatibility


Does the extension method AddEventLog of Microsoft.Extensions.Logging.ILoggingBuilder does also work when the application runs under a Linux OS or would it cause an exception when there is no Windows Event Log present?


Solution

  • No it does not. The event log is windows specific and in fact, if you do try to use it without checking for windows support explicitly, you will get a warning in the IDE:

    Image of visual studio showing the AddEventLog call with an analyzer warning because of the code is windows specific