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?
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:
In VSCode I do not get any warning. Not even via dotnet build.
0
To verify you can wrap it in a OS check like so
if (OperatingSystem.IsWindows()) {
builder.Logging.AddEventLog();
}
Even if the answer was yes/no today, there is no way to know what the future holds, so always check yourself to be safe. This also removes the warning that was mentioned.