On the local or server, write the Windows event log code, do not error, but open the Windows Event Log record panel, but do not see any records, it is likely that your current user does not have permission to write something. At this point, we do some configuration so that the current user has permission to write to the event log.
Settings: "Start-run", enter command, "regedt32", find "System->currentcontrolset->services->eventlog", and select "Security---rights--add" , and then find the "lilei" user of this machine, add in and give the Read permission just fine. But the premise is that you have a user who can add permissions. For example, I am now logged in to the machine user is a normal user A, after writing code, write not in. Then need the administrator to log in, according to the method above, give a permission, and then a and then log in, execute the code, you can write.
Note: Sometimes it is not just window Event log, which is written to a TXT file in a directory for debugging purposes after the program Windows Service is deployed to the server. But looking at the log log file, but found nothing in it, but the program did not throw an exception, it is likely that your Windows service uses the account, there is no write to this directory to allow the permissions. The sample code is written to the log file using Enterprise Libarry logging.
Namespace loggingapplication{ class program { static void Main (string[] args) { //Create a log entry LogEntry log = new LogEntry (); Specifies the category log to which the journal belongs . Categories.add ("Fixed"); Journal header log . Title = "SHY520 ' s Tests"; Log. Message = "There is log information"; Priority Log. Priority = 0; Logger.write (log); Console.ReadLine ();}}}