You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Jack Warner (JIRA)" <ji...@apache.org> on 2019/05/14 17:42:00 UTC

[jira] [Commented] (LOG4NET-552) Add new locking model to the FileAppender that works fine when multiple processes log and roll the same file

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

Jack Warner commented on LOG4NET-552:
-------------------------------------

This is still broken in the latest (at this time) 2.0.8.0 version.

Using a simple test harness that writes messages from multiple threads to the same file using RollingFileAppender for 10 seconds, and launching multiple instances of the application as well, so multiple processes and multiple threads are hitting the same log...

Using InterprocessLock mode the application hangs apparently when it rolls the file.

Using MinimalLock doesn't hang but the processes/threads are not cooperating on the file roll, so log messages get lost. For instance it should have logged about 1MB worth of messages with 5 rolled files of about 200KB each, but ended up only logging about 90K worth of messages and screwed up the rolled files.

This needs to cooperate properly, not just for multi-thread safety but multi-process safety.

In practice this may not be a real issue because we won't normally be hitting the logging system that hard. But it is possible that 2 applications could be logging a single message at the same time and both decide it's time to roll the file and mess things up in the act.

> Add new locking model to the FileAppender that works fine when multiple processes log and roll the same file
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4NET-552
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-552
>             Project: Log4net
>          Issue Type: New Feature
>          Components: Appenders
>    Affects Versions: 1.2.15
>         Environment: Any
>            Reporter: Sachin Abaso Patil
>            Priority: Major
>         Attachments: Modification in AdjustFileBeforeAppend.png
>
>
> 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
(v7.6.3#76005)