© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•16mo ago•
2 replies
Justin Grote

Microsoft.Extensions.Logging dynamic log level?

Hello,

I am working on a LSP Server that uses the omnisharp LSP, which uses MEL for logging. I would like the ability for someone to change the logging level in the client (e.g. vscode) and have the logging level update to the requested level of verbosity. From what I can find, this is amazingly, not part of MEL design, and the recommended way to do this is in a downstream provider that supports it, such as N4Log, etc. but unfortunately one of my log providers is at the MEL provider level (provided by onmisharp), and I don't want to reimplement it at the downstream provider level.

I was looking at how
SetMinimumLevel
SetMinimumLevel
works and it seems to register an option that configs the logs, I was thinking maybe it's possible? The DI is such a rats nest of non-type-resolved injections I have no idea where such an option is being referenced, and if it makes a copy so that changes are immutable or if it is a reference so changes would reflect to downstream providers, thus making dynamic changes possible.

Is this a crazy idea or is there prior art for this? Seems like it would be a fairly common request/issue. Thanks all!

Reference: https://stackoverflow.com/questions/70688658/changing-net-minimum-log-level-programmatically
Stack Overflow
Changing .NET Minimum Log Level programmatically
Using Microsoft.Extensions.Logging, let be the log initialization (F#):
let myLogger =
LoggerFactory
.Create(fun builder ->
builder
.AddSimpleConsole()
...
Changing .NET Minimum Log Level programmatically
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Microsoft.Extensions.Logging.Console
C#CC# / help
2y ago
`Microsoft.Extensions.Logging` and Serilog compatible timing library?
C#CC# / help
2y ago
✅ Scoped-based logging: Microsoft interface
C#CC# / help
3y ago