Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How do I go about allowing the ASP.NET account to write to the windows event log?

I am trying to create a new 'source' in the event log and its not playing :(

I think I can create the log by hand in the registry but this seems cumbersome. I'd rather let the code do it.

If I do have to do it manually, how do I create a new 'directory' in the registry under...

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\EventLog
share|improve this question

1 Answer 1

up vote 0 down vote accepted

This might be a better question for StackOverflow. However, I'll give my 2c anyway.

Since creating an event source only needs to happen once on a particular machine, you shouldn't really code your app (particularly a web app that's already running with limited privs) to create that source on demand. Granting additional permissions for the lifetime of the app just to accommodate a single call would be silly.

Instead, the event source creation should take place as part of the app's installer or as a separate manual step in the deployment instructions if there is no installer. Using a manual step doesn't have to mean hand-editing the registry. It can be a separate tiny console app who's sole purpose is to setup the event source.

All your app should worry about is actually writing to the log. Definitely keep in the code that checks for the source to exist. But if it doesn't find it, gracefully degrade and find an alternative way to notify the site admin like a simple error page.

share|improve this answer
    
Yeah I agree. Im trying to find the easiest way of creating the log to begin with because i'm being lazy! I'd upvote your answer if I had enough rep myself!! –  Matt Nov 20 '09 at 9:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.