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?


Check out the EventLogPermission attribute.

  • Where might I find that attribute? – Pieces Jul 12 '10 at 4:09
  • See the discussion at secnewsgroups.net/dotnet/… 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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