I'm still learning .NET and .NET Core, and I'm struggling a little bit with logging. So I was hoping someone can point me down the right path....
I'm implementing Serilog in my .NET Core 2.0.0 web application, and the basics seem to be working. However, I can't seem to output "LogDebug" and "LogTrace" to my Serilog rolling file. All I can get are Information events and higher. Are we able to output these 2 types of events?
For testing, within ConfigureServices in Startup.cs I have this:
Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.RollingFile("Logs\\test.txt") .CreateLogger();
In my controller I have this:
private readonly ILogger<HomeController> _logger; public HomeController(ILogger<HomeController> logger) { _logger = logger; } public IActionResult MyActionForTesting() { _logger.LogDebug("Debug TEST"); _logger.LogInformation("Information TEST"); _logger.LogWarning("Warning TEST"); _logger.LogError("Error TEST"); _logger.LogTrace("Trace TEST"); _logger.LogCritical("Critical/Fatal TEST"); }
But my test log file only has this:
2017-10-05 11:19:26.000 -05:00 [Information] Information TEST 2017-10-05 11:19:26.003 -05:00 [Warning] Warning TEST 2017-10-05 11:19:26.006 -05:00 [Error] Error TEST 2017-10-05 11:19:26.009 -05:00 [Fatal] Critical/Fatal TEST
What do I need to do to log the other 2 event types in case I ever need that information?
Thanks!