2

I have an ASP.NET Core 2.0 application using Microsoft.Extensions.Logging.EventLog to log to Windows Event Viewer with

.ConfigureLogging((hostingContext, logging) =>
{
  logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
  logging.AddEventLog();
  logging.AddConsole();
})

On Event Viewer I can see my application working and logging itself to it, but it has the default name of Application under Source, and I'm trying to figure out on how to change it's name so it can Log under a different source name.

Yitzak Hernandez
  • 355
  • 4
  • 23
  • It would be a good idea in the future to check the documentation, as you could have found your answer faster and without taking up anyone else's time had you done a little research. – mason May 29 '18 at 15:44

1 Answers1

5

You can control that by passing an EventLogSettings to the extension method that adds logging.

var eventLogSettings = new EventLogSettings
{
    LogName = "Something",
    SourceName = "Something 2"
};

logging.AddEventLog(eventLogSettings);
mason
  • 31,774
  • 10
  • 77
  • 121