Skip to content

Conversation

chrisbbe
Copy link

We have issues where log events with LogLevel.None are written to Seq, which it should not according to MS LogLevel documentation

@nblumhardt
Copy link
Member

Thanks for the PR!

This seems reasonable on the surface, but probably indicates a bug further up the stack in your logging pipeline: loggers shouldn't construct events or invoke providers with the None level.

There's an ILogger.Error() method, for example, but no ILogger.None() method. How are these events being created in the first place?

@chrisbbe
Copy link
Author

That's the reason for the IsEnabled(LogLevel) method: to check which logger is enabled for the given level, before the event enters the provider.

It's correct that you don’t have a specific ILogger.None(), but there is the more general Log(ILogger, LogLevel, ...) commonly used when the level is dynamically determined during runtime.

@nblumhardt
Copy link
Member

That's the reason for the IsEnabled(LogLevel) method: to check which logger is enabled for the given level, before the event enters the provider.

I don't think that's necessarily the case. In the documentation you linked, note that the description for None begins with:

Not used for writing log messages.

This is different from "Used when a log message shouln't be written". The None value is a filter, it's not a valid level on events, and even code that calls ILogger.Log() dynamically should never call this method with the None value.

There's still possibly a bug somewhere, but it's likely to be in whatever is calling the IsEnabled() function. Happy to help track it down if you can send any further details.

Cheers!

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

Successfully merging this pull request may close these issues.

2 participants