logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sachin Abaso Patil (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4NET-552) Incorrect behavior of RollingFileAppender while rolling files, if multiple processes appending into same file
Date Tue, 14 Mar 2017 12:29:41 GMT

    [ https://issues.apache.org/jira/browse/LOG4NET-552?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15924088#comment-15924088

Sachin Abaso Patil commented on LOG4NET-552:

Hi Dominik,

Thanks for your response. 

As you know we have multiple processes writing into same log file using RollingFileAppender.
Following are three important settings of RollingFileAppender we have set. And due to this
after every hour rolling of log file happens.
      <datePattern value=".yyyyMMddHH'.log'"/>
      <rollingStyle value="Composite" />
      <param name="LockingModel" type="log4net.Appender.FileAppender+MinimalLock" />

Problem we have seen is with above setting is, suppose there are 5 processes running on same
machine which uses same RollingFileAppender setttings as described above. When hour changes,
process 1 rolls (File.Move) main log file (say "log.txt" with size 5 MB) with rolled file
named "log.txt.2017031415.log". So, now rolled file has size 5 MB and main log file has size
0 bytes. Now 2nd process will also detect hour change and will try to roll main file with
is of 0 bytes with rolled file name "log.txt.2017031415.log". Thus, rolled file data vanishes.
This is the problem we are facing.

We have looked into code where rolling happens for RollingFileAppender. Inside RollingFileAppender.cs
there is method 
protected void RollFile(string fromFile, string toFile)
This method has code to delete destination if exists. We are thinking this is causing above

Could you please let us know,
1. Why DeleteFile(toFile); call is made inside method protected void RollFile(string fromFile,
string toFile) of RollingFileAppender.cs ?
2. We are thinking to modify method protected void RollFile(string fromFile, string toFile)
of RollingFileAppender.cs in such a way that if destination file (toFile) exists then don't
do anything. Let us know your comments on this change.

Thanks in advance.

Sachin Patil

> Incorrect behavior of RollingFileAppender while rolling files, if multiple processes
appending into same file
> -------------------------------------------------------------------------------------------------------------
>                 Key: LOG4NET-552
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-552
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.15
>         Environment: Windows Server 2008 R2 Enterprise
>            Reporter: Sachin Abaso Patil
>            Priority: Blocker
> Hi Team,
> This issue has become blocker for us, as on our production environment, multiple processes
are appending log into single log file which has no issue, but while rolling it overwrites
files and thus missing log entries.
> Based on link below, it looks like log file rolling mechanism of log4net is not process
safe even after using FileAppender.InterProcessLock. 
> Link: https://issues.apache.org/jira/browse/LOG4NET-485
> Also, in FAQ (https://logging.apache.org/log4net/release/faq.html) under section “How
do I get multiple process to log to the same file?”, it has been clearly mentioned that,
rolling files is simply not compatible with multiple process scenario.
> My questions,
> 1.	We are using version “1.2.15”. Are you planning to fix above mentioned rolling
issue in upcoming release? If yes then please provide tentative release date.
> 2.	We had incorporated log4net in our project in year 2009, had FAQ mentioned this limitation
(rolling file not compatible with multi process) in year 2009? Because we while studying log4net
during year 2009 we do not remember seeing this note in FAQ?
> Requesting you to please respond as soon as possible with your comments.
> Below is how we have configured appender for all processes,
>     <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
>     <threshold value ="ERROR"/>
>     <file value="${SystemDrive}\LogFiles\Example.log" />
>     <param name="LockingModel" type="log4net.Appender.FileAppender+MinimalLock" />
>     <appendToFile value="true" />
>     <maximumFileSize value="100MB" />
>     <staticLogFileName value="true"/>
>     <maxSizeRollBackups value="-1" />
>     <countDirection value="1" />
>     <datePattern value=".yyyyMMddHH'.log'"/>
>     <rollingStyle value="Composite" />
>     <ignoreExceptionItemAgeLimit value="false" />
>     <exceptionItemAgeLimit value="00:00:59" />
>     <layout type="log4net.Layout.PatternLayout">
>       <param name="conversionPattern" value ="%utcdate{yyyy-MM-dd HH:mm:ss.fff}|%-5level|%property{EventID}|%property{log4net:HostName}|%appdomain|%property{ProcessID}|%thread|%message%newline"/>
>     </layout>
>   </appender>
> Thanks,
> Sachin Patil

This message was sent by Atlassian JIRA

View raw message