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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With