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

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:

XML
<log4net>
    <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">
        <!--http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html-->
        <conversionPattern value="%date{dd-MMM-yy, HH:mm:ss} - %5level [%thread] - %message%newline " />
      </layout>
    </appender>
    <root>
      <!-- Ascending Priority: Debug,Info,Warn,Error,Fatal,ALL -->
      <priority value="ALL" />
      <appender-ref ref="RollingLogFileAppender" />
    </root>



Regards,
Jitendra Zaa
Posted
Updated 7-Sep-10 21:32pm
v2
Comments
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
log4net.Config.XmlConfigurator.ConfigureAndWatch(
  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
 
Comments
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