I added email logging to my .net core application, like here:
https://github.com/shawnwildermuth/WilderBlog/tree/master/src/WilderBlog/Logger
using the following in Startup.cs
loggerfactory.AddEmail(mailService, Microsoft.Extensions.Logging.LogLevel.Critical);
LogLevel.Critical:
Logs that describe an unrecoverable application or system crash, or a catastrophic failure that requires immediate attention
So I set out to test this in a controller action:
public ContentResult ProduceError()
{
var foo = new StackOverflower();
System.Console.WriteLine(foo.MyText);
return Content("<html><body></body></html>", "text/html");
}
public class StackOverflower
{
private string m_MyText;
public string MyText
{
get { return MyText; }
set { this.m_MyText = value; }
}
}
But this logs NOTHING.
Now, since the logging works fine for non-critical errors, I have one question:
If it can't log critical errors, why have a LogLevel for it ?
Or am I missing something ?