Write to Windows Event Log

S

-Steve-

I have code that calls System.Diagnostics.EventLog.WriteEntry to write
exceptions to the windows app event log. However by default you have to be
an admin to write to the application event log.

Is the best way to enable this to give write permissions to
C:\WINDOWS\system32\config\AppEvent.evt or is there a better way to handle
this?

Steve
 
B

Brian P

Maybe you could use impersonation to switch to an admin user to write to
the event log. Haven't done this before, but it seems like it would
fit. Not sure what kind of side-effects it might have, but it seems
like you could impersonate an admin, write the log entry, and then let
go of the impersonated admin.

Look into System.Security.Principal.WindowsIdentity.Impersonate

--Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top