You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4php-dev@logging.apache.org by "Kyle Wiering (JIRA)" <ji...@apache.org> on 2012/10/09 22:24:03 UTC

[jira] [Created] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Kyle Wiering created LOG4PHP-196:
------------------------------------

             Summary: 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
             Fix For: 2.3.0


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

[jira] [Comment Edited] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Charles Mack (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475005#comment-13475005 ] 

Charles Mack edited comment on LOG4PHP-196 at 10/12/12 2:12 PM:
----------------------------------------------------------------

Ivan,

Let me see if I can setup a few more tests locally including the Trunk log4php code.   If I can get it to replicate, I'll create post a Youtube clip and instructions.  I suspect that you are not able to replicate this because the file copy is too quick when rolling (because of file size) and the writes are too short (because of log message size).  

I greatly appreciate your help and patience. 
                
      was (Author: cfmack):
    Ivan,

Let me see if I can setup a few more tests locally including the Trunk log4php code.   If I can get it to replicate, I'll create post a Youtube clip and instructions.  I greatly appreciate your help and patience. 
                  
> 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, fileroller.php, filewriter.php, 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

[jira] [Commented] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Ivan Habunek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474420#comment-13474420 ] 

Ivan Habunek commented on LOG4PHP-196:
--------------------------------------

Hi guys. I appreciate your contribution! It may take a little while for me to get around to reviewing the code. We're just now pushing out version 2.3.0.

Just as a matter of curiosity, have you tried out the latest code from trunk? There have been some substantial improvements in the way rollover is performed. Notably, the files are locked using flock() while writing and rollover are performed. This should, I think, prevent problems such as the ones you mention. However, I have not tested scenarios such as yours so I'm not sure it works. :)

You can see the latest code here:
https://github.com/apache/log4php/blob/trunk/src/main/php/appenders/LoggerAppenderRollingFile.php

                
> 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, fileroller.php, filewriter.php, 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

[jira] [Commented] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Charles Mack (JIRA)" <ji...@apache.org>.
    [ 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

[jira] [Comment Edited] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Charles Mack (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475005#comment-13475005 ] 

Charles Mack edited comment on LOG4PHP-196 at 10/12/12 2:11 PM:
----------------------------------------------------------------

Ivan,

Let me see if I can setup a few more tests locally including the Trunk log4php code.   If I can get it to replicate, I'll create post a Youtube clip and instructions.  I greatly appreciate your help and patience. 
                
      was (Author: cfmack):
    Ivan,

Let me see if I can setup a few more tests locally including the Trunk log4php code.   If I can get it to replicate, I'll create post a Youtube clip and instructions.
                  
> 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, fileroller.php, filewriter.php, 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

[jira] [Commented] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Ivan Habunek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474845#comment-13474845 ] 

Ivan Habunek commented on LOG4PHP-196:
--------------------------------------

Tried with large strings, and 50MB rollover, like you suggested. I get 20 files, and it still works as expected.  
{code}
>cat logs/* > logs.txt
>wc -l logs.txt
1000000 logs.txt
{code}

I'll try it over a network later today.
                
> 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, fileroller.php, filewriter.php, 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

[jira] [Commented] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Kyle Wiering (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474439#comment-13474439 ] 

Kyle Wiering commented on LOG4PHP-196:
--------------------------------------

Yes, I had tested with the latest code and ran into the exact problem Steve describes.  Also - the rollOver method has a strong possibility of collisions. 
                
> 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, fileroller.php, filewriter.php, 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

[jira] [Commented] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Howe, Steve (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474651#comment-13474651 ] 

Howe, Steve commented on LOG4PHP-196:
-------------------------------------

I'm currently out of the office, returning Tuesday 10/16.

If you are in need of immediate assistance please contact Charles Mack.

Thanks,
Steve

                
> 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, fileroller.php, filewriter.php, 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

[jira] [Commented] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Ivan Habunek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474502#comment-13474502 ] 

Ivan Habunek commented on LOG4PHP-196:
--------------------------------------

Interesting. I'm trying to reproduce the bug locally. Take the following code:
https://gist.github.com/3874964

I start 10 processes logging to the same file at the same time, 100.000 iterations each. Rollover is set at 100KB. When processes finish, there's 135 files. That means 134 rollovers.

Now if I concat the 135 files into one, and count the number of lines, I get exactly 1 million. Therefore, I have not lost anything. 

I tried this a couple of times. I conclude that locking works as intended locally, at least on my 64bit Windows 7. It's a small step forward. :)

What I think could be a problem is the fact that you're logging over a network (you mentioned UNC paths). As far as I can tell, SMB [does support locking|http://en.wikipedia.org/wiki/Server_Message_Block#Opportunistic_locking], but frankly, I don't know how reliably this works. I'll give it a go tomorrow on the work network.

Can you tell me which version of windows you are running?
                
> 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, fileroller.php, filewriter.php, 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

[jira] [Updated] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Ivan Habunek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ivan Habunek updated LOG4PHP-196:
---------------------------------

    Fix Version/s:     (was: 2.3.0)
    
> 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
>         Attachments: config_roll_windows.xml, fileroller.php, filewriter.php, 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

[jira] [Updated] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Kyle Wiering (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kyle Wiering updated LOG4PHP-196:
---------------------------------

    Attachment:     (was: config_roll_windows.xml)
    
> 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

[jira] [Commented] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Charles Mack (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13475005#comment-13475005 ] 

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

Ivan,

Let me see if I can setup a few more tests locally including the Trunk log4php code.   If I can get it to replicate, I'll create post a Youtube clip and instructions.
                
> 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, fileroller.php, filewriter.php, 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

[jira] [Updated] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Kyle Wiering (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kyle Wiering updated LOG4PHP-196:
---------------------------------

    Attachment: config_roll_windows.xml
                LoggerAppenderRollingFileWindowsTest.php
                LoggerAppenderRollingFileWindows.php
                LoggerAutoloader.php
    
> 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: 0.4h
>  Remaining Estimate: 0.4h
>
> 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

[jira] [Updated] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Kyle Wiering (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kyle Wiering updated LOG4PHP-196:
---------------------------------

    Remaining Estimate: 24h  (was: 0.4h)
     Original Estimate: 24h  (was: 0.4h)
    
> 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

[jira] [Commented] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Charles Mack (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474647#comment-13474647 ] 

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

I am unable to test this until tomorrow but I suspect that is because the file is writing such a small amount and opens and closes quickly.

Try swapping:
{code}
for ($i = 0; $i < 100000; $i++) {
    $logger->debug($i);
}
{code}

With this:
{code}
for ($i = 0; $i < 100000; $i++) {  
  $testString = $i . str_pad(" ", 10000, ' ') 
  $logger->debug($testString );
}
{code}

Also, the maxFileSize is set pretty small, meaning the file copying is quick. Try 50MB over 100 kbs.   The idea is to "trick" a process to keeping the file that is being rolled open.   Now that I that way, it does seem like a pretty extreme use case but I would rather 10 50 mb files over several hundred 100kb files.

This has been replicated on Windows 7 64-bit and Windows 2003 Server 32-bit.  I cannot attest for the current github version though.
                
> 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, fileroller.php, filewriter.php, 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

[jira] [Commented] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Ivan Habunek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474872#comment-13474872 ] 

Ivan Habunek commented on LOG4PHP-196:
--------------------------------------

I tried logging over an UNC path to a shared folder on my local machine (something like "\\mymachine\share\logs\rolling.log") and it just doesn't work.

All the rolled over files are empty, except for a bunch of \0 symbols.

{code}
d:\share\logs>dir
 Volume in drive D is Storage
 Volume Serial Number is 689C-3320

 Directory of d:\share\logs

12.10.2012  09:56    <DIR>          .
12.10.2012  09:56    <DIR>          ..
12.10.2012  09:56            30.043 rolling.log
12.10.2012  09:56             8.192 rolling.log.1
12.10.2012  09:56             8.192 rolling.log.2
12.10.2012  09:56             8.192 rolling.log.3
12.10.2012  09:55             8.192 rolling.log.4
12.10.2012  09:55             8.192 rolling.log.5
12.10.2012  09:55             8.192 rolling.log.6
               7 File(s)         79.195 bytes
               2 Dir(s)  25.227.177.984 bytes free
{code}

The rollover was set to 100KB. So the locking apparently does not work as well over SMB.

The interesting thing is that the exact same thing happens if I use your LoggerAppenderRollingFileWindows.

                
> 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, fileroller.php, filewriter.php, 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

[jira] [Commented] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Steve Howe (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13474433#comment-13474433 ] 

Steve Howe commented on LOG4PHP-196:
------------------------------------

Hey Ivan. I'm not sure if Kyle tested this bug in the latest code, however I don't think flock() will solve the issue when *multiple* PHP processes are trying to read/write/roll the log file on Windows. (Think multiple Windows CLI php-win.exe processes running and trying to roll the same log file at the near/same time.)

The PHP documentation on flock() is a bit cryptic, but the 2nd "Warning" doc block in the Notes section mentions the limitations of flock() on Windows here: http://php.net/manual/en/function.flock.php

Some other posts relating to the limitation of flock() on Windows:
* http://bytes.com/topic/php/answers/487428-php-instances-writing-same-file
* http://cubicspot.blogspot.com/2010/10/forget-flock-and-system-v-semaphores.html

Thanks for your help with this, Ivan! Hopefully it will help someone else too.
                
> 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, fileroller.php, filewriter.php, 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

[jira] [Updated] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Kyle Wiering (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kyle Wiering updated LOG4PHP-196:
---------------------------------

    Attachment: config_roll_windows.xml
    
> 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

[jira] [Updated] (LOG4PHP-196) Appender Rolling File: Seperate PHP processes attempting to roll the same log file will truncate the log.

Posted by "Kyle Wiering (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4PHP-196?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kyle Wiering updated LOG4PHP-196:
---------------------------------

    Attachment: filewriter.php
                fileroller.php

Attaching two files used for a 'simplified' test. 
* From different windows command prompts:
** php filewriter.php
** php fileroller.php
** php fileroller.php
** etc.
                
> 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, fileroller.php, filewriter.php, 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