ASP.NET Core logging too verbose
I'm having trouble with configuration logging in ASP.NET Core 2.1 WebApi application. I successfuly achieved logging messages to Azure and inspecting them in Log stream, however these logs are too verbose. I don't want to have messages from category Microsoft.AspNetCore
to be logged in information level. This is my logging section in appsettings.json
file:
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore.Hosting.Internal.WebHost": "Debug",
"GameHub": "Information"
}
}
And my Program
class:
public class Program
{
public static void Main(string args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureAppConfiguration((hostingContext, config) => { config.AddJsonFile("appsettings.json", optional:true, reloadOnChange:true); })
.ConfigureLogging((ctx, logging) =>
{
logging.AddConfiguration(ctx.Configuration.GetSection("Logging"));
});
}
It still logs messages from category Microsoft.AspNetCore
in information level, instead of debug level.
What am I doing wrong?
c# azure logging asp.net-core
add a comment |
I'm having trouble with configuration logging in ASP.NET Core 2.1 WebApi application. I successfuly achieved logging messages to Azure and inspecting them in Log stream, however these logs are too verbose. I don't want to have messages from category Microsoft.AspNetCore
to be logged in information level. This is my logging section in appsettings.json
file:
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore.Hosting.Internal.WebHost": "Debug",
"GameHub": "Information"
}
}
And my Program
class:
public class Program
{
public static void Main(string args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureAppConfiguration((hostingContext, config) => { config.AddJsonFile("appsettings.json", optional:true, reloadOnChange:true); })
.ConfigureLogging((ctx, logging) =>
{
logging.AddConfiguration(ctx.Configuration.GetSection("Logging"));
});
}
It still logs messages from category Microsoft.AspNetCore
in information level, instead of debug level.
What am I doing wrong?
c# azure logging asp.net-core
Yes, of course, because you told it so:"Default": "Debug",
You said, debug everything from Debug Level and higher, which is almost everything (the only higher debug Level is Trace iirc). You have to set it to"Default": "Warning",
(because the next higher debugging level is Information)
– Tseng
Nov 24 '18 at 11:27
add a comment |
I'm having trouble with configuration logging in ASP.NET Core 2.1 WebApi application. I successfuly achieved logging messages to Azure and inspecting them in Log stream, however these logs are too verbose. I don't want to have messages from category Microsoft.AspNetCore
to be logged in information level. This is my logging section in appsettings.json
file:
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore.Hosting.Internal.WebHost": "Debug",
"GameHub": "Information"
}
}
And my Program
class:
public class Program
{
public static void Main(string args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureAppConfiguration((hostingContext, config) => { config.AddJsonFile("appsettings.json", optional:true, reloadOnChange:true); })
.ConfigureLogging((ctx, logging) =>
{
logging.AddConfiguration(ctx.Configuration.GetSection("Logging"));
});
}
It still logs messages from category Microsoft.AspNetCore
in information level, instead of debug level.
What am I doing wrong?
c# azure logging asp.net-core
I'm having trouble with configuration logging in ASP.NET Core 2.1 WebApi application. I successfuly achieved logging messages to Azure and inspecting them in Log stream, however these logs are too verbose. I don't want to have messages from category Microsoft.AspNetCore
to be logged in information level. This is my logging section in appsettings.json
file:
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore.Hosting.Internal.WebHost": "Debug",
"GameHub": "Information"
}
}
And my Program
class:
public class Program
{
public static void Main(string args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureAppConfiguration((hostingContext, config) => { config.AddJsonFile("appsettings.json", optional:true, reloadOnChange:true); })
.ConfigureLogging((ctx, logging) =>
{
logging.AddConfiguration(ctx.Configuration.GetSection("Logging"));
});
}
It still logs messages from category Microsoft.AspNetCore
in information level, instead of debug level.
What am I doing wrong?
c# azure logging asp.net-core
c# azure logging asp.net-core
asked Nov 24 '18 at 10:51
DoniosDonios
375
375
Yes, of course, because you told it so:"Default": "Debug",
You said, debug everything from Debug Level and higher, which is almost everything (the only higher debug Level is Trace iirc). You have to set it to"Default": "Warning",
(because the next higher debugging level is Information)
– Tseng
Nov 24 '18 at 11:27
add a comment |
Yes, of course, because you told it so:"Default": "Debug",
You said, debug everything from Debug Level and higher, which is almost everything (the only higher debug Level is Trace iirc). You have to set it to"Default": "Warning",
(because the next higher debugging level is Information)
– Tseng
Nov 24 '18 at 11:27
Yes, of course, because you told it so:
"Default": "Debug",
You said, debug everything from Debug Level and higher, which is almost everything (the only higher debug Level is Trace iirc). You have to set it to "Default": "Warning",
(because the next higher debugging level is Information)– Tseng
Nov 24 '18 at 11:27
Yes, of course, because you told it so:
"Default": "Debug",
You said, debug everything from Debug Level and higher, which is almost everything (the only higher debug Level is Trace iirc). You have to set it to "Default": "Warning",
(because the next higher debugging level is Information)– Tseng
Nov 24 '18 at 11:27
add a comment |
2 Answers
2
active
oldest
votes
As sellotape said, the loglevel set in .NET Core is the minimum level.
When you set Debug
, it will log Critical, Error, Warning, Information, Debug
levels. It will not log Trace
(highest verbosity).
If you don't want Information
, you set it to Warning
, then you only get Critical, Error, Warning
logged.
However, if you want Critical, Error, Warning, Debug
without the Information, you can't do that directly with the appsettings.json
.
public static class Program
{
public static void Main(string args) => CreateWebHostBuilder(args).Build().Run();
public static IWebHostBuilder CreateWebHostBuilder(string args) =>
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) => { ... })
.ConfigureLogging((webhostContext, builder) => {
builder.AddConfiguration(webhostContext.Configuration.GetSection("Logging"))
.AddFilter<ConsoleLoggerProvider>(logLevel => logLevel!=LogLevel.Information)
.AddConsole()
.AddDebug();
})
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights();
}
The
// by strong typedProvider
.AddFilter<ConsoleLoggerProvider>(logLevel => logLevel!=LogLevel.Information)
// or by name
.AddFilter("Console", logLevel => logLevel != LogLevel.Information)
// or generic/global
.AddFilter(logLevel => logLevel != LogLevel.Information)
adds logging filter with one of three predicates (Func<string, string, LogLevel, bool>
, Func<string, LogLevel, bool>
, Func<LogLevel, bool>
) as seen in the ASP.NET Core Documentation:
Filter functions
A filter function is invoked for all providers and categories that don't have rules assigned to them by configuration or code. Code in the function has access to the provider type, category, and log level. For example:
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureLogging(logBuilder =>
{
logBuilder.AddFilter((provider, category, logLevel) =>
{
if (provider == "Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider" &&
category == "TodoApiSample.Controllers.TodoController")
{
return false;
}
return true;
});
})
.Build();
add a comment |
Information level is above (or below, depending on how you see it) Debug level, and hence less verbose. If you set it to Debug, you also get all of Information (and Warning, Error). I doubt you can change it in the standard Core logging.
For reference, the logging levels across most logging frameworks, from most to least verbose, are:
Verbose,
Debug,
Information,
Warning,
Error,
Fatal
(Some frameworks use slightly different naming, as Tseng correctly notes in the comments below, but the basic idea remains the same).
On some frameworks - e.g. log4net - you can set the maximum as well as minimum levels, but AFAIK with Core's inbuilt logging, you set minimum only, and hence get everything above that as well.
Exactly, I am aware of this fact. So on Azure portal in Diagnostics logs section of my application I set Application Logging "On" with log level "Information". Shouldn't I get everything above the "Information" level then? (which means Warning, Error, Fatal levels)
– Donios
Nov 24 '18 at 11:20
For .NET Core abstractions, it'sTrace, Debug, Information, Warning, Error, Critical
– Tseng
Nov 24 '18 at 11:31
That's correct, but in your question you have the default level set to Debug, and your override forMicrosoft.AspNetCore.Hosting.Internal.WebHost
is to Debug as well (i.e. no effective difference). The logging you set forGameHub
is Information, so logging entries generated explicitly by classes whose namespace begins with that should show for Information and above only.
– sellotape
Nov 24 '18 at 11:34
@Donios: When you want to logCritical, Error, Warning, Information
you have to set"Xxx" : "Information"
, notDebug
, because Debug is more verbose. You can't exclude a "middlelevel" logging
– Tseng
Nov 24 '18 at 11:34
Read: You can't haveCritical, Error, Warning, Debug
because Information is less verbose than Debug. When you chose Debug, you will also getInformation
. If you want to excludeInformation
but getDebug
you will have to write your own logging provider (or configure that in the external Logging library if you use one). Well technically you can with filters, but its not as pretty
– Tseng
Nov 24 '18 at 11:41
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457386%2fasp-net-core-logging-too-verbose%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
As sellotape said, the loglevel set in .NET Core is the minimum level.
When you set Debug
, it will log Critical, Error, Warning, Information, Debug
levels. It will not log Trace
(highest verbosity).
If you don't want Information
, you set it to Warning
, then you only get Critical, Error, Warning
logged.
However, if you want Critical, Error, Warning, Debug
without the Information, you can't do that directly with the appsettings.json
.
public static class Program
{
public static void Main(string args) => CreateWebHostBuilder(args).Build().Run();
public static IWebHostBuilder CreateWebHostBuilder(string args) =>
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) => { ... })
.ConfigureLogging((webhostContext, builder) => {
builder.AddConfiguration(webhostContext.Configuration.GetSection("Logging"))
.AddFilter<ConsoleLoggerProvider>(logLevel => logLevel!=LogLevel.Information)
.AddConsole()
.AddDebug();
})
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights();
}
The
// by strong typedProvider
.AddFilter<ConsoleLoggerProvider>(logLevel => logLevel!=LogLevel.Information)
// or by name
.AddFilter("Console", logLevel => logLevel != LogLevel.Information)
// or generic/global
.AddFilter(logLevel => logLevel != LogLevel.Information)
adds logging filter with one of three predicates (Func<string, string, LogLevel, bool>
, Func<string, LogLevel, bool>
, Func<LogLevel, bool>
) as seen in the ASP.NET Core Documentation:
Filter functions
A filter function is invoked for all providers and categories that don't have rules assigned to them by configuration or code. Code in the function has access to the provider type, category, and log level. For example:
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureLogging(logBuilder =>
{
logBuilder.AddFilter((provider, category, logLevel) =>
{
if (provider == "Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider" &&
category == "TodoApiSample.Controllers.TodoController")
{
return false;
}
return true;
});
})
.Build();
add a comment |
As sellotape said, the loglevel set in .NET Core is the minimum level.
When you set Debug
, it will log Critical, Error, Warning, Information, Debug
levels. It will not log Trace
(highest verbosity).
If you don't want Information
, you set it to Warning
, then you only get Critical, Error, Warning
logged.
However, if you want Critical, Error, Warning, Debug
without the Information, you can't do that directly with the appsettings.json
.
public static class Program
{
public static void Main(string args) => CreateWebHostBuilder(args).Build().Run();
public static IWebHostBuilder CreateWebHostBuilder(string args) =>
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) => { ... })
.ConfigureLogging((webhostContext, builder) => {
builder.AddConfiguration(webhostContext.Configuration.GetSection("Logging"))
.AddFilter<ConsoleLoggerProvider>(logLevel => logLevel!=LogLevel.Information)
.AddConsole()
.AddDebug();
})
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights();
}
The
// by strong typedProvider
.AddFilter<ConsoleLoggerProvider>(logLevel => logLevel!=LogLevel.Information)
// or by name
.AddFilter("Console", logLevel => logLevel != LogLevel.Information)
// or generic/global
.AddFilter(logLevel => logLevel != LogLevel.Information)
adds logging filter with one of three predicates (Func<string, string, LogLevel, bool>
, Func<string, LogLevel, bool>
, Func<LogLevel, bool>
) as seen in the ASP.NET Core Documentation:
Filter functions
A filter function is invoked for all providers and categories that don't have rules assigned to them by configuration or code. Code in the function has access to the provider type, category, and log level. For example:
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureLogging(logBuilder =>
{
logBuilder.AddFilter((provider, category, logLevel) =>
{
if (provider == "Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider" &&
category == "TodoApiSample.Controllers.TodoController")
{
return false;
}
return true;
});
})
.Build();
add a comment |
As sellotape said, the loglevel set in .NET Core is the minimum level.
When you set Debug
, it will log Critical, Error, Warning, Information, Debug
levels. It will not log Trace
(highest verbosity).
If you don't want Information
, you set it to Warning
, then you only get Critical, Error, Warning
logged.
However, if you want Critical, Error, Warning, Debug
without the Information, you can't do that directly with the appsettings.json
.
public static class Program
{
public static void Main(string args) => CreateWebHostBuilder(args).Build().Run();
public static IWebHostBuilder CreateWebHostBuilder(string args) =>
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) => { ... })
.ConfigureLogging((webhostContext, builder) => {
builder.AddConfiguration(webhostContext.Configuration.GetSection("Logging"))
.AddFilter<ConsoleLoggerProvider>(logLevel => logLevel!=LogLevel.Information)
.AddConsole()
.AddDebug();
})
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights();
}
The
// by strong typedProvider
.AddFilter<ConsoleLoggerProvider>(logLevel => logLevel!=LogLevel.Information)
// or by name
.AddFilter("Console", logLevel => logLevel != LogLevel.Information)
// or generic/global
.AddFilter(logLevel => logLevel != LogLevel.Information)
adds logging filter with one of three predicates (Func<string, string, LogLevel, bool>
, Func<string, LogLevel, bool>
, Func<LogLevel, bool>
) as seen in the ASP.NET Core Documentation:
Filter functions
A filter function is invoked for all providers and categories that don't have rules assigned to them by configuration or code. Code in the function has access to the provider type, category, and log level. For example:
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureLogging(logBuilder =>
{
logBuilder.AddFilter((provider, category, logLevel) =>
{
if (provider == "Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider" &&
category == "TodoApiSample.Controllers.TodoController")
{
return false;
}
return true;
});
})
.Build();
As sellotape said, the loglevel set in .NET Core is the minimum level.
When you set Debug
, it will log Critical, Error, Warning, Information, Debug
levels. It will not log Trace
(highest verbosity).
If you don't want Information
, you set it to Warning
, then you only get Critical, Error, Warning
logged.
However, if you want Critical, Error, Warning, Debug
without the Information, you can't do that directly with the appsettings.json
.
public static class Program
{
public static void Main(string args) => CreateWebHostBuilder(args).Build().Run();
public static IWebHostBuilder CreateWebHostBuilder(string args) =>
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) => { ... })
.ConfigureLogging((webhostContext, builder) => {
builder.AddConfiguration(webhostContext.Configuration.GetSection("Logging"))
.AddFilter<ConsoleLoggerProvider>(logLevel => logLevel!=LogLevel.Information)
.AddConsole()
.AddDebug();
})
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights();
}
The
// by strong typedProvider
.AddFilter<ConsoleLoggerProvider>(logLevel => logLevel!=LogLevel.Information)
// or by name
.AddFilter("Console", logLevel => logLevel != LogLevel.Information)
// or generic/global
.AddFilter(logLevel => logLevel != LogLevel.Information)
adds logging filter with one of three predicates (Func<string, string, LogLevel, bool>
, Func<string, LogLevel, bool>
, Func<LogLevel, bool>
) as seen in the ASP.NET Core Documentation:
Filter functions
A filter function is invoked for all providers and categories that don't have rules assigned to them by configuration or code. Code in the function has access to the provider type, category, and log level. For example:
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.ConfigureLogging(logBuilder =>
{
logBuilder.AddFilter((provider, category, logLevel) =>
{
if (provider == "Microsoft.Extensions.Logging.Console.ConsoleLoggerProvider" &&
category == "TodoApiSample.Controllers.TodoController")
{
return false;
}
return true;
});
})
.Build();
answered Nov 24 '18 at 12:23
TsengTseng
34.3k595124
34.3k595124
add a comment |
add a comment |
Information level is above (or below, depending on how you see it) Debug level, and hence less verbose. If you set it to Debug, you also get all of Information (and Warning, Error). I doubt you can change it in the standard Core logging.
For reference, the logging levels across most logging frameworks, from most to least verbose, are:
Verbose,
Debug,
Information,
Warning,
Error,
Fatal
(Some frameworks use slightly different naming, as Tseng correctly notes in the comments below, but the basic idea remains the same).
On some frameworks - e.g. log4net - you can set the maximum as well as minimum levels, but AFAIK with Core's inbuilt logging, you set minimum only, and hence get everything above that as well.
Exactly, I am aware of this fact. So on Azure portal in Diagnostics logs section of my application I set Application Logging "On" with log level "Information". Shouldn't I get everything above the "Information" level then? (which means Warning, Error, Fatal levels)
– Donios
Nov 24 '18 at 11:20
For .NET Core abstractions, it'sTrace, Debug, Information, Warning, Error, Critical
– Tseng
Nov 24 '18 at 11:31
That's correct, but in your question you have the default level set to Debug, and your override forMicrosoft.AspNetCore.Hosting.Internal.WebHost
is to Debug as well (i.e. no effective difference). The logging you set forGameHub
is Information, so logging entries generated explicitly by classes whose namespace begins with that should show for Information and above only.
– sellotape
Nov 24 '18 at 11:34
@Donios: When you want to logCritical, Error, Warning, Information
you have to set"Xxx" : "Information"
, notDebug
, because Debug is more verbose. You can't exclude a "middlelevel" logging
– Tseng
Nov 24 '18 at 11:34
Read: You can't haveCritical, Error, Warning, Debug
because Information is less verbose than Debug. When you chose Debug, you will also getInformation
. If you want to excludeInformation
but getDebug
you will have to write your own logging provider (or configure that in the external Logging library if you use one). Well technically you can with filters, but its not as pretty
– Tseng
Nov 24 '18 at 11:41
|
show 1 more comment
Information level is above (or below, depending on how you see it) Debug level, and hence less verbose. If you set it to Debug, you also get all of Information (and Warning, Error). I doubt you can change it in the standard Core logging.
For reference, the logging levels across most logging frameworks, from most to least verbose, are:
Verbose,
Debug,
Information,
Warning,
Error,
Fatal
(Some frameworks use slightly different naming, as Tseng correctly notes in the comments below, but the basic idea remains the same).
On some frameworks - e.g. log4net - you can set the maximum as well as minimum levels, but AFAIK with Core's inbuilt logging, you set minimum only, and hence get everything above that as well.
Exactly, I am aware of this fact. So on Azure portal in Diagnostics logs section of my application I set Application Logging "On" with log level "Information". Shouldn't I get everything above the "Information" level then? (which means Warning, Error, Fatal levels)
– Donios
Nov 24 '18 at 11:20
For .NET Core abstractions, it'sTrace, Debug, Information, Warning, Error, Critical
– Tseng
Nov 24 '18 at 11:31
That's correct, but in your question you have the default level set to Debug, and your override forMicrosoft.AspNetCore.Hosting.Internal.WebHost
is to Debug as well (i.e. no effective difference). The logging you set forGameHub
is Information, so logging entries generated explicitly by classes whose namespace begins with that should show for Information and above only.
– sellotape
Nov 24 '18 at 11:34
@Donios: When you want to logCritical, Error, Warning, Information
you have to set"Xxx" : "Information"
, notDebug
, because Debug is more verbose. You can't exclude a "middlelevel" logging
– Tseng
Nov 24 '18 at 11:34
Read: You can't haveCritical, Error, Warning, Debug
because Information is less verbose than Debug. When you chose Debug, you will also getInformation
. If you want to excludeInformation
but getDebug
you will have to write your own logging provider (or configure that in the external Logging library if you use one). Well technically you can with filters, but its not as pretty
– Tseng
Nov 24 '18 at 11:41
|
show 1 more comment
Information level is above (or below, depending on how you see it) Debug level, and hence less verbose. If you set it to Debug, you also get all of Information (and Warning, Error). I doubt you can change it in the standard Core logging.
For reference, the logging levels across most logging frameworks, from most to least verbose, are:
Verbose,
Debug,
Information,
Warning,
Error,
Fatal
(Some frameworks use slightly different naming, as Tseng correctly notes in the comments below, but the basic idea remains the same).
On some frameworks - e.g. log4net - you can set the maximum as well as minimum levels, but AFAIK with Core's inbuilt logging, you set minimum only, and hence get everything above that as well.
Information level is above (or below, depending on how you see it) Debug level, and hence less verbose. If you set it to Debug, you also get all of Information (and Warning, Error). I doubt you can change it in the standard Core logging.
For reference, the logging levels across most logging frameworks, from most to least verbose, are:
Verbose,
Debug,
Information,
Warning,
Error,
Fatal
(Some frameworks use slightly different naming, as Tseng correctly notes in the comments below, but the basic idea remains the same).
On some frameworks - e.g. log4net - you can set the maximum as well as minimum levels, but AFAIK with Core's inbuilt logging, you set minimum only, and hence get everything above that as well.
edited Nov 24 '18 at 11:36
answered Nov 24 '18 at 11:02
sellotapesellotape
5,69821619
5,69821619
Exactly, I am aware of this fact. So on Azure portal in Diagnostics logs section of my application I set Application Logging "On" with log level "Information". Shouldn't I get everything above the "Information" level then? (which means Warning, Error, Fatal levels)
– Donios
Nov 24 '18 at 11:20
For .NET Core abstractions, it'sTrace, Debug, Information, Warning, Error, Critical
– Tseng
Nov 24 '18 at 11:31
That's correct, but in your question you have the default level set to Debug, and your override forMicrosoft.AspNetCore.Hosting.Internal.WebHost
is to Debug as well (i.e. no effective difference). The logging you set forGameHub
is Information, so logging entries generated explicitly by classes whose namespace begins with that should show for Information and above only.
– sellotape
Nov 24 '18 at 11:34
@Donios: When you want to logCritical, Error, Warning, Information
you have to set"Xxx" : "Information"
, notDebug
, because Debug is more verbose. You can't exclude a "middlelevel" logging
– Tseng
Nov 24 '18 at 11:34
Read: You can't haveCritical, Error, Warning, Debug
because Information is less verbose than Debug. When you chose Debug, you will also getInformation
. If you want to excludeInformation
but getDebug
you will have to write your own logging provider (or configure that in the external Logging library if you use one). Well technically you can with filters, but its not as pretty
– Tseng
Nov 24 '18 at 11:41
|
show 1 more comment
Exactly, I am aware of this fact. So on Azure portal in Diagnostics logs section of my application I set Application Logging "On" with log level "Information". Shouldn't I get everything above the "Information" level then? (which means Warning, Error, Fatal levels)
– Donios
Nov 24 '18 at 11:20
For .NET Core abstractions, it'sTrace, Debug, Information, Warning, Error, Critical
– Tseng
Nov 24 '18 at 11:31
That's correct, but in your question you have the default level set to Debug, and your override forMicrosoft.AspNetCore.Hosting.Internal.WebHost
is to Debug as well (i.e. no effective difference). The logging you set forGameHub
is Information, so logging entries generated explicitly by classes whose namespace begins with that should show for Information and above only.
– sellotape
Nov 24 '18 at 11:34
@Donios: When you want to logCritical, Error, Warning, Information
you have to set"Xxx" : "Information"
, notDebug
, because Debug is more verbose. You can't exclude a "middlelevel" logging
– Tseng
Nov 24 '18 at 11:34
Read: You can't haveCritical, Error, Warning, Debug
because Information is less verbose than Debug. When you chose Debug, you will also getInformation
. If you want to excludeInformation
but getDebug
you will have to write your own logging provider (or configure that in the external Logging library if you use one). Well technically you can with filters, but its not as pretty
– Tseng
Nov 24 '18 at 11:41
Exactly, I am aware of this fact. So on Azure portal in Diagnostics logs section of my application I set Application Logging "On" with log level "Information". Shouldn't I get everything above the "Information" level then? (which means Warning, Error, Fatal levels)
– Donios
Nov 24 '18 at 11:20
Exactly, I am aware of this fact. So on Azure portal in Diagnostics logs section of my application I set Application Logging "On" with log level "Information". Shouldn't I get everything above the "Information" level then? (which means Warning, Error, Fatal levels)
– Donios
Nov 24 '18 at 11:20
For .NET Core abstractions, it's
Trace, Debug, Information, Warning, Error, Critical
– Tseng
Nov 24 '18 at 11:31
For .NET Core abstractions, it's
Trace, Debug, Information, Warning, Error, Critical
– Tseng
Nov 24 '18 at 11:31
That's correct, but in your question you have the default level set to Debug, and your override for
Microsoft.AspNetCore.Hosting.Internal.WebHost
is to Debug as well (i.e. no effective difference). The logging you set for GameHub
is Information, so logging entries generated explicitly by classes whose namespace begins with that should show for Information and above only.– sellotape
Nov 24 '18 at 11:34
That's correct, but in your question you have the default level set to Debug, and your override for
Microsoft.AspNetCore.Hosting.Internal.WebHost
is to Debug as well (i.e. no effective difference). The logging you set for GameHub
is Information, so logging entries generated explicitly by classes whose namespace begins with that should show for Information and above only.– sellotape
Nov 24 '18 at 11:34
@Donios: When you want to log
Critical, Error, Warning, Information
you have to set "Xxx" : "Information"
, not Debug
, because Debug is more verbose. You can't exclude a "middlelevel" logging– Tseng
Nov 24 '18 at 11:34
@Donios: When you want to log
Critical, Error, Warning, Information
you have to set "Xxx" : "Information"
, not Debug
, because Debug is more verbose. You can't exclude a "middlelevel" logging– Tseng
Nov 24 '18 at 11:34
Read: You can't have
Critical, Error, Warning, Debug
because Information is less verbose than Debug. When you chose Debug, you will also get Information
. If you want to exclude Information
but get Debug
you will have to write your own logging provider (or configure that in the external Logging library if you use one). Well technically you can with filters, but its not as pretty– Tseng
Nov 24 '18 at 11:41
Read: You can't have
Critical, Error, Warning, Debug
because Information is less verbose than Debug. When you chose Debug, you will also get Information
. If you want to exclude Information
but get Debug
you will have to write your own logging provider (or configure that in the external Logging library if you use one). Well technically you can with filters, but its not as pretty– Tseng
Nov 24 '18 at 11:41
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457386%2fasp-net-core-logging-too-verbose%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Yes, of course, because you told it so:
"Default": "Debug",
You said, debug everything from Debug Level and higher, which is almost everything (the only higher debug Level is Trace iirc). You have to set it to"Default": "Warning",
(because the next higher debugging level is Information)– Tseng
Nov 24 '18 at 11:27