Reputation: 17264
In asp.net core it is possible to register the different logging providers:
services.AddLogging(builder => builder
.AddConsole()
.AddDebug();
Then configure inside appsetttings.json:
{
"Logging": {
"IncludeScopes": false,
"Console": {
"LogLevel": {
"Default": "Warning"
}
}
}
}
But how do I configure the log level for a custom logging provider:
builder.Services.AddSingleton<ILoggerProvider,MyLoggerProvider>
What should be added to appsettings.json and what should be done in code? I am guessing something like:
{
"Logging": {
"IncludeScopes": false,
"Console": {
"LogLevel": {
"Default": "Warning"
}
}
"?":{
"LogLevel": {
"Default": "Debug"
}
}
}
}
But what goes in "?" if indeed this is the correct approach?
Upvotes: 0
Views: 656
Reputation: 637
You can use the ProviderAlias attribute on your CustomLoggerProvider class and add that Alias to appsettings.json file.
[ProviderAlias("MyLogger")]
public class MyLoggerProvider
"MyLogger":{
"LogLevel": {
"Default": "Debug"
}
}
Upvotes: 3