Does Event logger in C# needs admin privileges to write logs into Windows Event Viewer?

[亡魂溺海] 提交于 2019-12-10 12:48:24

问题


In my C# application I am using EventLog class to log messages. It works perfectly fine on my machine but doesnt really works on client machine.

Client machine configuration is different than my machine. My machine has Vista OS whereas client has Windows 2003 OS.

I have admin rights on my machine whereas on client machine my application runs under non-admin user previleges.

On client machine I get error as Faulting application , version ,faulting module kernel32.dll

My application stopped crashing on client machine when I commented out EventLog.WriteEntry() method calls and started to write logs into simple text file.

So I was just wondering whether event logging needs administrator privileges or what?

Enviornment details : C#, .net 2.0 framework, Windows Vista, Windows 2003 server, Oracle


回答1:


System.Diagnostics.EventLog class in .NET Framework 3.5 @ MSDN:

If you write to an event log, you must specify or create an event Source. You must have administrative rights on the computer to create a new event source.




回答2:


One solution is to create the required Event Source in your application installer, which runs with admin rights. See http://support.microsoft.com/default.aspx?scid=kb;EN-US;329291



来源:https://stackoverflow.com/questions/3930529/does-event-logger-in-c-sharp-needs-admin-privileges-to-write-logs-into-windows-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!