Adding permission explicitly to the EventLog key (and all
subkeys) seems to have done the trick.
Maybe this should be added to the FAQ... :)
On 10/11/05, Hollywood <[EMAIL PROTECTED]> wrote:
> I've been running into this lately. One of the items is to make sure your
> have permissions to the event log to write with.
>
> Check the HKLM\System\CurrrentControlSet\EventLog and make sure whatever
> user your process (if WinForms the logged on user or if ASP the
> website/webservices' AppPool user) has write permissions to it.
>
> My appender looks like the following (although the appender config is from a
> slightly older version of log4net):
>
> <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
>
>
> <param name="LogName" value="Application"/>
>
> <param name="ApplicationName" value="AppName"/>
>
>
> <layout type="log4net.Layout.PatternLayout,log4net">
>
> <param name="Header" value="[Log Header]\r\n"/>
>
> <param name="Footer" value="[Log Footer]\r\n"/>
>
> <param name="ConversionPattern" value="%c%n[%-5p] %d{ISO8601} .%m%n %x"/>
>
> </layout>
>
>
> <filter type="log4net.Filter.LevelRangeFilter">
>
> <levelMin value="ERROR" />
>
> <levelMax value="FATAL" />
>
> </filter>
>
>
> </appender>
>
>
> ----- Original Message -----
> From: "Billy Barnum" <[EMAIL PROTECTED]>
> To: "'Log4NET User'" <[email protected]>; "'Matthew Brown'"
> <[EMAIL PROTECTED]>
> Sent: Tuesday, October 11, 2005 5:20 PM
> Subject: RE: Inability to use EventLogAppender with ASPNET
>
>
> Try removing your line:
>
> <logName value="Application"/>
>
> I think what you're doing there is naming a custom EventLog with the same
> name as the existing Application log, which in turn requires write access to
> the registry. Just remove that line and see what happens.
>
> -BillyB
>
>
>
> WILLIAM BARNUM
> [EMAIL PROTECTED]
>
> ________________________________________
> From: Matthew Brown [mailto:[EMAIL PROTECTED]
> Sent: Monday, October 10, 2005 1:43 PM
> To: Log4NET User
> Subject: Inability to use EventLogAppender with ASPNET
>
> 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(XmlEleme
> nt 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
>
>