Creating an application and event logs in the “app

2019-06-24 12:19发布

问题:

I have a .NET application in which I want to write unhandled events to the event viewer. I noticed that there is a directory called "Applications and Services Logs". I would like to create an entry for my application in this directory and write any unhandled events to it. Unfortunately, I can't find any documentation.

Is this even possible? If so, how?

Thanks!

回答1:

You can create a log entry with this method :

public static void CreateEventSource(
    string YourApplication,
    string YourLogName    )

CreateEventSource

Doc: 1: http://msdn.microsoft.com/en-us/library/2awhba7a.aspx

Example :Eventlog



标签: c# event-log