C# create Windows event logs by EventLog.

1. What's Windows event logs.

 

A: MSDN event logs http://support.microsoft.com/kb/308427

  

  • Application log

    The application log contains events logged by programs. For example, a database program may record a file error in the application log. Events that are written to the application log are determined by the developers of the software program.
  • Security log

    The security log records events such as valid and invalid logon attempts, as well as events related to resource use, such as the creating, opening, or deleting of files. For example, when logon auditing is enabled, an event is recorded in the security log each time a user attempts to log on to the computer. You must be logged on as Administrator or as a member of the Administrators group in order to turn on, use, and specify which events are recorded in the security log.
  • System log

    The system log contains events logged by Windows XP system components. For example, if a driver fails to load during startup, an event is recorded in the system log. Windows XP predetermines the events that are logged by system components.

 

2.  We create an user-defined Log.

  

using  System.Diagnostics
EventLog.WriteEntry(
"A1", uninstallCmd);


 

 3. Now we can see the log file in windows.

 

 

posted on 2010-11-25 14:32  zencorn  阅读(334)  评论(0编辑  收藏  举报