Click here to Skip to main content
15,845,120 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Log4net is working fine in my windows application but whenever I use same config in Windows service, Rollingappender does not work
All logs are written in same file. If you know some thing about this behavior then please reply.

Find the config setting:

    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="Logs/Notification.log" />
      <appendToFile value="true" />
      <rollingStyle value="Date" />
      <datePattern value="-dd-MMM-yy" />
      <!--Roll every Day-->
      <maxSizeRollBackups value="-1" />
      <!--Infinite backups-->
      <maximumFileSize value="2MB" />
      <!--Maximum size of 1 file-->
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date{dd-MMM-yy, HH:mm:ss} - %5level [%thread] - %message%newline " />
      <!-- Ascending Priority: Debug,Info,Warn,Error,Fatal,ALL -->
      <priority value="ALL" />
      <appender-ref ref="RollingLogFileAppender" />

Jitendra Zaa
Updated 7-Sep-10 22:32pm
Dalek Dave 8-Sep-10 3:32am    
Minor Edit for Grammar.

1 solution

Have you added the 'Watch Configuration' to your Service assembly?

e.g. using XML configuration
  new System.IO.FileInfo("log4net.config"));

e.g or the DOMConfigurator (deprecated?) assembly attribute

// Log4Net watch XML attribute
[assembly: log4net.Config.DOMConfigurator(Watch=true)] 

When my appenders aren't working, it's normally this step I've forgotten!
Share this answer
Jitendra Zaa 8-Sep-10 4:26am    
I haven't used it. I will try and revert. Thanks for reply

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900