writing error in windows event viewer using MSD axapta

You can use this job to put in its class to write a warning or error in windows event viewer

 System.Diagnostics.EventLog     eventLog;  
   LogText               nameLog = "Dynamics AX India";  
   LogText               sourceLog = "Log test";  
   ;  
   if(!System.Diagnostics.EventLog::SourceExists(sourceLog))  
   {  
     System.Diagnostics.EventLog::CreateEventSource(sourceLog, nameLog);  
   }  
   eventlog = new System.Diagnostics.EventLog();  
   eventlog.set_Source(sourceLog);  
   eventlog.WriteEntry("Test log event viewer!");  
   eventlog.WriteEntry("Erro! Teste error. \n\n" +  
     con2str(xSession::xppCallStack()), System.Diagnostics.EventLogEntryType::Error);  
   eventlog.WriteEntry("test abc" , System.Diagnostics.EventLogEntryType::Warning);  
   info("show event viewer!");