Problem when trying to use EventLog.SourceExists method in .NET

后端 未结 4 1994
旧时难觅i
旧时难觅i 2021-01-03 21:31

I am trying to use eventlogs in my application using C#, so I added the following code

if (!EventLog.SourceExists(\"SomeName\"))
EventLog.CreateEventSource(\         


        
4条回答
  •  情歌与酒
    2021-01-03 22:04

    Short tip:

    One event source is registered during Service instalation (if application is Windows Service), and can be used without Security Exception with low-profile process owner (not Administrator)

    I perform service installation / run with C# code in typical way from SO/ MSDN

    Important is property ServiceName in class System.ServiceProcess.ServiceBase .

提交回复
热议问题