Event logging permissions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have been looking at tutorials on event logging and utilising the EventLog class. The code shown in these tutorials will typically be as shown below:

EventLog ev = new EventLog()
ev.Log = "Application"
ev.Source = "Test"
ev.WriteEntry("test entry")

When I try and run this on my own development environment however I get an exception thrown stating that "Requested registry access is not allowed.". I can get round this by making giving the ASPNET user administrator rights. A similar exception is thrown if I try and use the static methods 'SourceExists' or 'CreateEventSource'.
Is making ASPNET an administrator required for this to work or is there another permission setting that I am missing

Regards, Andy
 
This might be useful for you.

http://support.microsoft.com/default.aspx?scid=kb;en-us;329291


Andy Rose said:
I have been looking at tutorials on event logging and utilising the
EventLog class. The code shown in these tutorials will typically be as shown
below:
EventLog ev = new EventLog();
ev.Log = "Application";
ev.Source = "Test";
ev.WriteEntry("test entry");

When I try and run this on my own development environment however I get an
exception thrown stating that "Requested registry access is not allowed.". I
can get round this by making giving the ASPNET user administrator rights. A
similar exception is thrown if I try and use the static methods
'SourceExists' or 'CreateEventSource'.
Is making ASPNET an administrator required for this to work or is there
another permission setting that I am missing.
 
Thank you Alex, this article has confirmed what I believed what was happening. It's just a little unnerving that books that descibe themselves as teaching 'Professional ASP.NET' and 'MCAD/MSCD' tutorials do not make any reference to this but instead imply that ASP.NET will happily create new Event log sources without any problems. Anyway rant over and thanks for your help.
 
P.S. There's a third way too: set <identity impersonate="true"/> in web.config to "temporarily" give the worker process rights to create the log (presuming whoever you're signed on as has those rights)

----- Andy Rose wrote: ----

Thank you Alex, this article has confirmed what I believed what was happening. It's just a little unnerving that books that descibe themselves as teaching 'Professional ASP.NET' and 'MCAD/MSCD' tutorials do not make any reference to this but instead imply that ASP.NET will happily create new Event log sources without any problems. Anyway rant over and thanks for your help.
 
Back
Top