Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Write to EventLog in .Net Core

I need a way to write to Windows' event viewer in my app that's using dnx. But, the EventLog class isn't available in the System.Diagnostics namespace so I'm stuck. Is there any other way to write to the EventViewer?

like image 535
Ameno acids Avatar asked Aug 24 '16 19:08

Ameno acids


People also ask

Where does EventLog WriteEntry write to?

The WriteEntry method writes the given string directly to the event log; it does not use a localizable message resource file. Use the WriteEvent method to write events using a localized message resource file.

How do you write to event log in Biztalk orchestration?

Writing to the Application LogSource = "This Application's Name"; appLog. WriteEntry("An entry to the Application event log."); If you are using a custom log, you should use the SourceExists method to ensure it exists before you write to it.

What is the use of ILogger in .NET Core?

ILoggerFactory is a factory interface that we can use to create instances of the ILogger type and register logging providers. It acts as a wrapper for all the logger providers registered to it and a logger it creates can write to all the logger providers at once.


1 Answers

Add from NuGet Microsoft.Extensions.Logging.EventLog Version 2.1.1

CM> Install-Package Microsoft.Extensions.Logging.EventLog -Version 2.1.1

Include the namespace Microsoft.Extensions.Logging.EventLog in the Program.cs file

This resolved my problem.

like image 101
praveen Avatar answered Oct 01 '22 10:10

praveen