Closed cilerler closed 5 years ago
Hi Cengiz,
Turns out, to my surprise, you must call SetMinimumLevel()
on the ILoggingBuilder
to drop the global logging level, first:
loggingBuilder.SetMinimumLevel(LogLevel.Trace);
loggingBuilder.AddSeq(Configuration.GetSection("Seq"));
I don't know whether this is really the expected usage pattern, so digging in a little further.
@pakrym, is there any blog post or doc on how minimum level is managed in v2?
Cheers!
(Especially - how should this work with level overrides? If I bump up the logging level for "Some.Component"
to Trace
, does this mean the global level now needs to be set to Trace
?)
@nblumhardt https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging?tabs=aspnetcore2x (How filtering rules are applied)
Minimum level is only used when there are no rules matched at all, so if you set Some.Component
to Trace
it would work fine with any minimum level.
@pakrym thanks for the follow-up!
Does that indicate we're hitting a bug here, then? In my test app, I have the Seq logger set to Trace, and level overrides defined in it for Microsoft and System, but still the global logging level of Information overrides everything else...
@nblumhardt do you have loggingBuilder.AddConfiguration(config)
call?
Do now, still not working as I'd expect, but more to dig through.
Currently going through the uncomfortable realization that, although there are technically no breaking API changes in 2.0, the entire configuration model used by the Serilog provider, Seq provider, and File provider is now completely broken?
Hacking in something like:
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Information"
},
"Seq": {
"LogLevel": {
"Default": "Trace",
"System": "Information",
"Microsoft": "Warning"
}
}
},
Does the framework recognize custom provider names here?
If you put ProviderAlias
attribute on you provider type, it's late bound so you don't need a package reference (see https://github.com/Microsoft/ApplicationInsights-aspnetcore/commit/205d73c1ed9f390455c9d7739c9aa1c9e0335dd5)
Thanks for the tip. Without ProviderAlias
, the provider won't work, then?
@nblumhardt full provider type name would work.
👍 thanks.
Any way we can get access to the logging configuration block, e.g. so that we can include custom data? E.g. ServerUrl
in:
"Logging": {
"Seq": {
"ServerUrl": "http://xyz",
"LogLevel": {
"Default": "Trace"
}
}
},
https://github.com/aspnet/Logging/issues/688
Will be there for 2.1
4.0.0-dev
looks just fine 👍 passed my all tests ✔️ Thank you 🤗 @nblumhardt @pakrym 🍪 ☕️
@nblumhardt we added a way to access provider configuration section in logging configuration: https://github.com/aspnet/Logging/pull/706
Thanks @pakrym, will take a look 👍
Closing this as I think it's now stale; will open a new ticket for configuration section support
Make sure you are looking for non-default levels which are Debug and Trace
Program.cs
appsettings.json
ConsoleApp1.csproj