serilog/serilog-extensions-logging-file

LogLevel.None not respected for Microsoft

riiight opened this issue · 7 comments

With this configuration...

"File": { "PathFormat": "Logs/MyLog_{Date}.txt", "LogLevel": { "Default": "Debug", "System": "None", "Microsoft": "None" } }

...Information level messages from Microsoft assemblies are still getting through. A temp workaround we are using is to set Microsoft and System to Critical.

Thanks, we should look at options to support this directly 👍

Anyone have any ideas of what to map Microsoft's LogLevel.None to? I'm not seeing a way to set Serilog to anything equivalent to none. And the default switch fall-through is picking Verbose/Trace. Which couldn't be farther from what is expected.

At the very least, I'm going to change the mapping so it's None->Critical. It's as close to the expected behavior as I can get. If anyone follows up with Serilog and convinces them to add None to their LogEventLevel or allows any way to turn off logging, I'll be happy to update this code.

(Side-note: I can actually think of one way to do it; but I don't like it. How do you guys feel about me putting in a configuration.ByExcluding() and filtering based on the source in the LogEvent? This would completely replace how it's currently filtering.)

Or perhaps throwing an exception about None not being supported would be the best behavior?

The least risky option (thus fastest to turn around) would be to map None to Fatal here - it's going to have the required effect, as in reality, I don't think anything in the framework is likely to raise Critical events. My vote is to make that change here as soon as possible.

It's probably also fine to map None to Fatal + 1, and eventually enshrine this value in Serilog as LevelAlias.Off, but more testing would be needed. A ticket and PR in serilog/serilog would probably be the way to move that one forward.

@kellystuard

If anyone follows up with Serilog

(That would be us! :-) .. this repository is part of the serilog organization - same people. Welcome!)

Glad to be here. Mapping to Fatal to begin with and will follow up with an issue and PR over at serilog/serilog. Probably should keep this issue open for further PR's, afterwards.

Fixed in #15