You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Paul Cowan <Pa...@jkd.co.uk> on 2005/08/17 15:06:10 UTC

EventLogAppender

I have the following appender

 

            <appender name="EventLogAppender"
type="log4net.Appender.EventLogAppender" >

                  <layout type="log4net.Layout.PatternLayout">

                        <param name="ConversionPattern" value="%d [%t]
%-5p %c [%x] - %m%n" />

                  </layout>

            </appender>

 

I simply cannot get any entries into the event log.  Has anyone any idea
why??


_____________________________________________________________________
VirusChecked for Huntsworth plc
_____________________________________________________________________

Re: EventLogAppender

Posted by Ron Grabowski <ro...@yahoo.com>.
I've never used the EventLogAppender before so this is a learning
experience for me too. 

When I copied your code into my log4net.config file for a ASP.Net
project I'm working on under Windows XP Pro I saw the following error
in my log4net log:

log4net:ERROR XmlHierarchyConfigurator: Could not create Appender
[EventLogAppender] of type [log4net.Appender.EventLogAppender].
Reported error follows.
System.Security.SecurityException: Requested registry access is not
allowed.
   at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean
writable)
   at System.Diagnostics.EventLog.FindSourceRegistration(String source,
String machineName, Boolean readOnly)
   at System.Diagnostics.EventLog.SourceExists(String source, String
machineName)
   at System.Diagnostics.EventLog.SourceExists(String source)
   at log4net.Appender.EventLogAppender.ActivateOptions()
   at
log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement
appenderElement)

That error led me to this article:

http://support.microsoft.com/default.aspx?scid=kb;en-us;329291

I copied the C# class into a new project and ran the code as described.
A InstallUtil.InstallLog file was created. It ended with the following
text:

"
The Commit phase completed successfully.

The transacted install has completed.
"

Does anyone know if its possible to uninstall the thing I just
installed?

I re-built my ASP.Net solution and saw the same message in my log4net
log file.

I found this log4net FAQ entry:

http://logging.apache.org/log4net/release/faq.html#trouble-EventLog

I'm not an EventLog guru so I'm curious why its not working as well. In
the KB article, they created a source called TEST. Is there a way to
set the source via the EventLogAppender? Do I need to set that? Is that
what the ApplicationName property on the EventLogAppender is for?

Thanks,
Ron

--- Paul Cowan <Pa...@jkd.co.uk> wrote:

> I have the following appender
> 
>  
> 
>             <appender name="EventLogAppender"
> type="log4net.Appender.EventLogAppender" >
> 
>                   <layout type="log4net.Layout.PatternLayout">
> 
>                         <param name="ConversionPattern" value="%d
> [%t]
> %-5p %c [%x] - %m%n" />
> 
>                   </layout>
> 
>             </appender>
> 
>  
> 
> I simply cannot get any entries into the event log.  Has anyone any
> idea
> why??
> 
> 
> _____________________________________________________________________
> VirusChecked for Huntsworth plc
> _____________________________________________________________________