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

Debug and Trace Log Level mapped to incorrect Source Levels #184

Closed
ATECoder opened this issue Feb 26, 2021 · 2 comments
Closed

Debug and Trace Log Level mapped to incorrect Source Levels #184

ATECoder opened this issue Feb 26, 2021 · 2 comments

Comments

@ATECoder
Copy link

I use Serilog to emit log messages to File, Trace and Console. I then use a TraceListener to filter the trace messages into a queue based on the trace SourceLevels, which I set to Warning (7).

My expectation is that only Error and Warning messages will appear in the queue. While, indeed, Information (SourceLevels 15 and LogLevel 2) messages are blocked, the queue shows both Trace [VRB] and Debug [DBG] messages which should have been mapped from 0, 1 to SourceLevels.Verbose (31).

Is this the expected behavior?

Is it possible that Trace and Debug levels are mapped lower than the SourceLevels.Warning (7) and thus are filtered in? I am aware that Serilog blocks out lower Log Levels whereas Trace Listener Filters block higher Source Levels. Seeing that Information (2) is blocked, as expected, I expected that both Debug and Trace will be blocked.

@Numpsy
Copy link
Member

Numpsy commented Feb 26, 2021

The Trace Sink uses specific trace functions for levels Information and higher, but just uses Trace.WriteLine for levels below information, which might effect that?

@ATECoder
Copy link
Author

ATECoder commented Feb 26, 2021

Yep, that will explain this behavior. It looks like the quick solution would be to fork this sink and add the debug and trace levels to the mix. Oh, I see, Trace is limited to levels at or below Information and does not expose the Trace Event method, which is encapsulated in the internal Trace Internal class.

Accepting this limitation, emitting Trace and Debug messages at the Information level will allow the blocking of these messages at the Information level, which better suites my needs. Issue 21

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

3 participants