Questions about writing to Windows log event without any records

Source: Internet
Author: User
Tags log log

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 ();}}}    



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.