With log4net internal debugging turned on, an attempt to create an EventLogAppender for a web application is failing:
[3616] log4net: XmlHierarchyConfigurator: Setting Property [Layout] to object [log4net.Layout.PatternLayout]
[3616] log4net: XmlHierarchyConfigurator: Setting Property [LogName] to String value [Application]
[3616] log4net:ERROR XmlHierarchyConfigurator: Could not create
Appender [EventLog] of type [log4net.Appender.EventLogAppender].
Reported error follows.
[3616] System.Security.SecurityException: Requested registry access is not allowed.
[3616] at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
[3616] at
System.Diagnostics.EventLog.FindSourceRegistration(String source,
String machineName, Boolean readOnly)
[3616] at System.Diagnostics.EventLog.SourceExists(String source, String machineName)
[3616] at System.Diagnostics.EventLog.SourceExists(String source)
[3616] at log4net.Appender.EventLogAppender.ActivateOptions()
[3616] at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)
[3616] log4net:ERROR XmlHierarchyConfigurator: Appender named [EventLog] not found.
[3616] log4net: XmlHierarchyConfigurator: Hierarchy Threshold []
[3616] log4net: AppenderSkeleton: Finalizing appender named [EventLog].
The FAQ on the log4net site says that the ASPNET account has permission
to write to the event log if created already. Just to be sure, I made
sure to add ASPNET and IUSR_machinename to the Administrators group,
but this does not work either.
Here is my configuration:
<appender name="EventLog" type="log4net.Appender.EventLogAppender" >
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date
[%thread][%mdc{AspNetSessionID}] %-5level %logger - %message%newline"
/>
</layout>
<logName value="Application"/>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="LogFileAppender" />
<appender-ref ref="EventLog" />
</root>
Sorry if this is a silly newbie question, but I couldn't find much out
there on configuring/using EventLogAppender besides "its tough". Can
anyone help?
Thanks,
Matt Brown
- Inability to use EventLogAppender with ASPNET Matthew Brown
- RE: Inability to use EventLogAppender with ASPNET Billy Barnum
- Re: Inability to use EventLogAppender with ASPNET Hollywood
- Re: Inability to use EventLogAppender with ASPN... Matthew Brown
- RE: Inability to use EventLogAppender with ... Billy Barnum
- Re: Inability to use EventLogAppender ... Matthew Brown
- Re: Inability to use EventLogAppen... Ron Grabowski
