Goal:
To create my own custom log under Applications and Services Logs under the Event Viewer:
Code snippet:
.Net CORE 3.1
Host.CreateDefaultBuilder(args)
.ConfigureLogging((hostContext, logging) =>
{
logging.ClearProviders();
logging.AddConfiguration(hostContext.Configuration.GetSection("Logging"));
logging.AddEventLog(
eventLogSettings =>
{
eventLogSettings.LogName = "My Log";
eventLogSettings.SourceName = "Dummy";
});
logging.AddConsole();
});
// somewhere in my code, I use ILogger to write to the log
Configuration
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Grpc": "Information",
"Microsoft": "Information"
}
}
Problem:
While testin my developer machine, I see the log entry on the console, but I don't see the log in the Event Viewer. If I dropped the LogName, the log shows up in the Application Log on the Event Viewer. What am I missing?
Thanks!