Using Log4Net EventLogAppender how to write event log to a custom one than writing to default ‘Application’ and set the Source column name?

Posted: March 15, 2011 in Log4Net
Tags: , , , ,

 To write to a different event log  specific to your project using Log4Net EventLogAppender,you need to set the LogName property.The default value of LogName is ‘Application’ & I have changed that to CustomEventLog here.The ApplicationName property indicates the name of your application,which is the ‘Source’ column in event viewer .

<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
      <param name="LogName" value="CustomEventLog" />
      <param name="ApplicationName" value="deeport" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%utcdate %newline %type %newline %method %newline %message %newline %exception"/>
<filter type="log4net.Filter.LevelRangeFilter">
<levelMin value="FATAL"/>
<levelMax value="FATAL"/>

 The advantage of customizing this way is,when you have to filter all event logs specific to your application it will be easy 🙂

  1. javaGuy says:

    This is cool.. I really wish all application programmers would read this. Would make life better for operations and support folks. !!

    Descriptions can be dynamically populated too, I think (?). I was wondering if we can clearly mark the exact details of the error this way.

  2. Anupama says:

    Thanks for dropping this note.Yes,it is possible using Fatal method
    ILog.Fatal Method (Object message, Exception exception)
    message -The message object to log.
    exception -The exception to log, including its stack trace.

  3. Useful information. Fortunate me I discovered your site by chance, and I am stunned why this coincidence did not happened in advance! I bookmarked it.

  4. rohan says:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s