Reputation: 203
I've searched and searched and can't find the answer. We have a custom service that runs and logs into the Event Viewer. In Windows 7, there's a folder called "Applications and Services Logs". How do I log an event in there? Is it even possible?
Upvotes: 2
Views: 2668
Reputation: 2146
It will happen automatically when you create a new Event Log using something like:
EventLog.CreateEventSource("Our Source", "Our Log");
And that call requires elevated privileges, but only needs to be done once. After that, you can reference with normal privileges using.
EventLog _eventLog = new EventLog("Our Log"); // Writes to OUR event log--NOT the system created "Application"
Note: If you are moving your source from Application
to your custom log, it may need some tweaking and/or a reboot as it is not normal to move a source from one log to another.
If you are using InstalUtil, you can also create the log using a System.Diagnostics.EventLogInstaller
Upvotes: 2