BlazorExtensions / Logging

Microsoft Extension Logging implementation for Blazor
MIT License
215 stars 32 forks source link

log with LogDebug level are never printed in console. #7

Closed dsaurel closed 6 years ago

dsaurel commented 6 years ago

Hi, i'm using you nuget package with Blazor 0.4. I've encountered a strange behaviour.

In Program.cs, // Add Blazor.Extensions.Logging.BrowserConsoleLogger services.AddLogging(builder => builder .AddBrowserConsole() // Register the logger with the ILoggerBuilder .SetMinimumLevel(LogLevel.Trace) // Set the minimum log level to Information );

Then i injected logger in an hypothetical BlazorComponent: [Inject] private ILogger<IndexComponent> _logger { get; set; }

Somewhere in a click triggered method:

_logger.LogDebug($"LogDebug {this.GetType().FullName}");
_logger.LogInformation($"LogInformation {this.GetType().FullName}");
_logger.LogWarning($"LogWarning {this.GetType().FullName}");
 _logger.LogTrace($"LogTrace {this.GetType().FullName}");
 _logger.LogCritical($"LogCritical {this.GetType().FullName}");

The message associated with logger.LogDebug is never printed in browser console.

Tested on Chrome Windows Version 67.0.3396.87 (Build officiel) (64 bits)

Thanks.

attilah commented 6 years ago

Hi @dsaurel!

This is not an issue with the logger, if you check in Edge or Firefox it just works.

The reason why you are not seeing it in Chrome is that from Chromium 58 the output of this method only appears when level Verbose is selected in the DevTools.

image

After enabling it you see the expected output:

image

dsaurel commented 6 years ago

Thanks 👍