try ~ catch 구문과 함께 Exception 발생 시 이벤트로그를 남길 수 있다.
[출처] http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx MSDN =^^=
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | using System; using System.Diagnostics; using System.Threading; class MySample{ public static void Main(){ // Create the source, if it does not already exist. if (!EventLog.SourceExists( "MySource" )) { //An event log source should not be created and immediately used. //There is a latency time to enable the source, it should be created //prior to executing the application that uses the source. //Execute this sample a second time to use the new source. EventLog.CreateEventSource( "MySource" , "MyNewLog" ); Console.WriteLine( "CreatedEventSource" ); Console.WriteLine( "Exiting, execute the application a second time to use the source." ); // The source is created. Exit the application to allow it to be registered. return ; } // Create an EventLog instance and assign its source. EventLog myLog = new EventLog(); myLog.Source = "MySource" ; // Write an informational entry to the event log. myLog.WriteEntry( "Writing to event log." ); } } |
[출처] http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.aspx MSDN =^^=