1

I am logging information into the windows event viewer.

This is what I have in my log4net config file.

  <logger name="MyLogger">
    <level value="all"/>
    <appender-ref ref="EventLogAppender"/>
  </logger>

      <!-- Windows Event Viewer appender -->
      <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
        </layout>
      </appender>

I'm seeing a new information event every time I'm logging with that logger in my application and I see that in Windows Event Viewer -> Windows Logs -> Application.

Is there a way to log in a specific journal or one that I create from my application?
Like instead of Application, it would be MyWebApplication.

Also, I have 2 web applications running at the same time. They both have their log4net config file with different loggers. It doesn't seem to work when I try to log events from the 2 web applications. (I set them different applicationName... <applicationName value="app1" /> <applicationName value="app2" />). It will always log with the first one name even if it's 2 different config file and 2 different applicationName.

Philipp M
  • 1,877
  • 7
  • 27
  • 38
vinhent
  • 2,692
  • 4
  • 17
  • 20
  • It has been answered before here: [Configuring a custom event log for log4net][1] [1]: http://stackoverflow.com/questions/2416800/configuring-a-custom-event-log-for-log4net – Steve Aug 06 '12 at 16:17
  • No, I want to know if I can have a personal one, not another one already existing like System. (wwithout manually creating it) – vinhent Aug 06 '12 at 19:19
  • I believe Steve's answer still holds. If the log file does not already exist, log4net will try to create it. However you should be aware that you will need administrative rights to **create** the new log file. – sgmoore Aug 06 '12 at 20:44
  • Well I just tried it with a random name and it didn't created it. But if we need administrative rights, it might create issues sometime for my application – vinhent Aug 06 '12 at 20:47
  • Can you create this from your code dynamically? If not, that will answer your question. log4net runs with no more privileges than that of your application. – Steve Aug 07 '12 at 16:26

0 Answers0