Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log Levels are not logged correctly #46

Open
grewegreg opened this issue Jan 8, 2023 · 0 comments
Open

Log Levels are not logged correctly #46

grewegreg opened this issue Jan 8, 2023 · 0 comments

Comments

@grewegreg
Copy link

When writing to the Event Viewer, the log levels Debug and Verbose are logged as Information, and Fatal is logged as Error.

In the file:

https://github.com/serilog/serilog-sinks-eventlog/blob/dev/src/Serilog.Sinks.EventLog/Sinks/EventLog/EventLogSink.cs

Is see the mapping:

static EventLogEntryType LevelToEventLogEntryType(LogEventLevel logEventLevel)
        {
            switch (logEventLevel)
            {
                case LogEventLevel.Debug: 
                case LogEventLevel.Information:
                case LogEventLevel.Verbose:
                    return EventLogEntryType.Information;

                case LogEventLevel.Error:
                case LogEventLevel.Fatal:
                    return EventLogEntryType.Error;

                case LogEventLevel.Warning:
                    return EventLogEntryType.Warning;

                default:
                    SelfLog.WriteLine("Unexpected logging level {0}, writing to the event log as `Information`", logEventLevel);
                    return EventLogEntryType.Information;
            }
        }


Since the [EventLogEntryType](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.eventlogentrytype?view=windowsdesktop-7.0) Enumeration does not contain Debug, Trace, or Fatal, can those Log Levels be written into Categories instead?


![WindowsEventViewer](https://user-images.githubusercontent.com/91921107/211178482-933d76c8-ba5b-469d-ad02-a813e5208948.png)
![WritingToWindowsEventViewer](https://user-images.githubusercontent.com/91921107/211178483-e91ff50a-91d4-42a1-9e14-435674fa891d.png)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant