Asp.Net Core 2.2, Visual Studio 2019, IIS 8.5 (I think)
I am stumped. In Asp.Net Core 2.2 where are log messages logged? I am missing something in the docs. The relevant sections of the Program.cs
and one of my controllers are below. I have assumed that the messages would end up in the Application Events but I am not seeing anything.
Program.cs
public class Program {
public static void Main(string[] args) {
CreateWebHostBuilder(args).Build().Run();
}
private static IWebHostBuilder CreateWebHostBuilder(string[] args) {
return WebHost.CreateDefaultBuilder(args)
.UseIIS()
.ConfigureLogging((hostingContext, logging) => {
logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
logging.AddDebug();
logging.AddEventSourceLogger();
logging.SetMinimumLevel(LogLevel.Debug);
})
.UseStartup<Startup>();
}
}
A Controller
public class AuthController : Controller {
private readonly ILogger _logger;
public AuthController(ILogger<AuthController> logger) {
_logger = logger;
}
[HttpGet]
public ActionResult Index() {
try {
_logger.LogDebug("Auth/Index: redirecting to /Auth/Login");
return Redirect("/Auth/Login");
} catch (Exception e) {
return Redirect("/Reservation/Index" + "?error=LOGIN_ERROR");
}
}
...
Edit
Based on a followup question below: After following advice from the link @RossBush shared I commented about having event Id issues. @TaoZhou picked up on that. I am seeing server eventLog messages like:
The description for Event ID 2 from source Application cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
Microsoft.AspNetCore.Hosting.Internal.WebHost
Request finished in 24.4311ms 302
the message resource is present but the message is not found in the string/message table