views:

43

answers:

1

Hello I have problem with EventLogAppender on the Windows7. Code for config EventLogAppender is:

       var elAppender = new EventLogAppender
            {
                ApplicationName = "MyLog",
                LogName = "MyLog",
                Layout = new PatternLayout(default_format),
                Threshold = Level.Error
            };

The error message is:

The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.

Could you help me to resolve this problem? Thanks.

+1  A: 

Did you turn off UAC? Or does your application run with elevated permissions? If not it will not work unless you create the event source manually before you run the application (maybe as part of an installer):

http://msdn.microsoft.com/en-us/library/system.diagnostics.eventlog.createeventsource.aspx

Stefan Egli