I've got a .net 3.1 core service and trying to write to a specific log file. Instead of going to new log, the loginformations are attempting to write to the application log. Getting: "The process was terminated due to an unhandled exception. Exception Info: System.AggregateException: An error occurred while writing to logger(s). (The source is not registered in log 'Application'. (It is registered in log .) "
The code to config in the createhostbuilder is
Host.CreateDefaultBuilder(args)
.UseWindowsService()
.ConfigureLogging((context, logging) =>
{
logging.AddEventLog(new EventLogSettings()
{
SourceName = <my service name>,
LogName = <custom log name>,
Filter = (x, y) => y >= LogLevel.Information
});
logging.AddConsole();
})
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Worker>();
});
Using ilogger and it's just a simple _logger.LogInformation("my message");