Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an ASP .Net app running on a windows 2003 server. If the application throws an exception I want the exception to be written to the event log. I have this implemented but when an exception is thrown I get a security exception because the server does not have permissions to write to the event log.

How do I enable this application permissions to write to the event log?

share|improve this question
up vote 1 down vote accepted

Check out the EventLogPermission attribute.

share|improve this answer
Where might I find that attribute? – Pieces Jul 12 '10 at 4:09
See the discussion at… As I understand it, the security settings of the assembly trying to add entries to the log doesn't have sufficient privileges to execute. Specifically, in order to write to the Event Log, your assembly must be granted the EventLogPermission attribute. If your assembly is only partially trusted then this will occur. You need to know Code Access Security to understand this. You may be better off creating your own independent log file to track exceptions thrown by your code. – John Miner Jul 15 '10 at 19:03
Cool thank you! – Pieces Jul 21 '10 at 14:12

Your Answer


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.