Event Viewer — log to sub folder?

▼魔方 西西 提交于 2019-12-11 03:26:42

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/12694536/event-viewer-log-to-sub-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!