18

I'm using log4net for logging (duh!). Using the EventLogAppender, I can configure my application name, so that my events will show up in the Application/"My Application Name" event log. However, I'd like to log events to "Some other event log"/"My Application Name". How do I configure that?

Current config:

<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
    <applicationName value="My application Name" />
    <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
    </layout>
</appender>

For an EventLogInstaller, the code would look like this:

eventLogInstaller.Log = "Some other event log"; // Default "Application"
eventLogInstaller.Source = "My application name";
Philipp M
  • 1,877
  • 7
  • 27
  • 38
Jonas Lincoln
  • 9,567
  • 9
  • 35
  • 49

1 Answers1

25

You control this with the LogName property.

E.g.:

<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
      <logName value="System" />
      <applicationName value="My application Name" />
      ...
</appender>
Philipp M
  • 1,877
  • 7
  • 27
  • 38
Peter Lillevold
  • 33,668
  • 7
  • 97
  • 131
  • 2
    I have done this and it did create the new log under the Event Viewer's `Applications and Services Logs` node, but the messages are still being logged to the `Application` log for some reason instead of the new one. – deadlydog Mar 03 '15 at 21:59
  • 4
    Nevermind, turns out I had to restart my computer for the change to take effect, as mentioned at http://stackoverflow.com/a/6457005/602585 and http://stackoverflow.com/questions/7607441/log4net-eventlogappender-is-ignoring-my-logname – deadlydog Mar 03 '15 at 22:42