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

Charles Mack commented on LOG4PHP-196:
--------------------------------------

To put this in context, Kyle and I work on a system that has hundreds of PHP 
threads writing to a single UNC path log.   (Yes, we are looking into Mongo to 
store our logs).   As a result, when running LoggerAppenderRollingFile in prod, 
the files get truncated randomly on NTFS.   

There are some test scripts to replicate this issue that we can attach. While 
this is an extreme case, I'm sure there exists web hosting scenarios where this 
occurs. We have lost huge amounts of logs because the lack of Windows file 
locking and the LoggerAppenderRollingFile, hampering some major debugging 
issues.   

The proposed approach does not guarantee that the file will get rolled 
immediately after the first write to the file where the file is over the max 
file size.   

LoggerAppenderRollingFileWindows rolls files when:
- The file is over the max file size
- There is not an existing file-based mutex on that file
- The file we are trying to roll is writable (meaning nothing else is actively 
writing to it)

The next opportunity to roll the file, the file will be rolled.   This can 
result in some odd file sizes.  The main theme is balance when to roll a file 
versus protecting existing logs from being overwritten.

Once attached, to replicate, run the attached scripts with 
LoggerAppenderRollingFileWindows and LoggerAppenderRollingFile.
                
> Appender Rolling File: Seperate PHP processes attempting to roll the same log 
> file will truncate the log.
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4PHP-196
>                 URL: https://issues.apache.org/jira/browse/LOG4PHP-196
>             Project: Log4php
>          Issue Type: Bug
>          Components: Code
>    Affects Versions: 2.2.1
>         Environment: Windows
>            Reporter: Kyle Wiering
>              Labels: bug, fix, patch
>             Fix For: 2.3.0
>
>         Attachments: config_roll_windows.xml, 
> LoggerAppenderRollingFileWindows.php, 
> LoggerAppenderRollingFileWindowsTest.php, LoggerAutoloader.php
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> Attaching a class extension to LoggerAppenderRollingFile named 
> LoggerAppenderRollingFileWindows. This class enacts 'blocking' to keep 
> seperate PHP processes from truncating the log file by attempting to roll the 
> logs at/near the same exact time.  It also uses a 'rename' in a manner that 
> is much quicker then a copy for large files.  

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to