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

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

1 Answer 1

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 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
    
Cool thank you! –  Pieces Jul 21 '10 at 14:12

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.