Log4php
  1. Log4php
  2. LOG4PHP-26

Add file locking to file appenders

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.0
    • Component/s: Code
    • Labels:
      None

      Description

      We should add file locking to all file appenders in order to prevent two or more processes accessing the same file at once which may lead to corrupt log files.

        Issue Links

          Activity

          Hide
          Christian Grobmeier added a comment -

          Yes, it can:
          closed with the resolution for LOG4PHP-71

          Show
          Christian Grobmeier added a comment - Yes, it can: closed with the resolution for LOG4PHP-71
          Hide
          Christian Hammers added a comment -

          LOG4PHP-71 is marked resolved - can this be closed as well?

          Show
          Christian Hammers added a comment - LOG4PHP-71 is marked resolved - can this be closed as well?
          Hide
          Christian Grobmeier added a comment -

          Please see: https://issues.apache.org/jira/browse/LOG4PHP-71

          Other processes (apache processes) need to wait until the file is unlocked. With flock (which is partially already implemented in the old versions) we have a file lock implementation. I would think that resolving LOG4PHP-71 resolves this issue too. Other file locking than flock seems odd to me.

          flock does support LOCK_NB mode, but this will not work on windows.

          Before having a not portable feature, I would think: leave it out, use flock to lock to manage mostly "nonblocking" writes and don't care, if other processes open the file.

          PLease see:
          http://blog.grobmeier.de/2009/08/21/performance-ofnonblocking-write-to-files-via-php.html

          Show
          Christian Grobmeier added a comment - Please see: https://issues.apache.org/jira/browse/LOG4PHP-71 Other processes (apache processes) need to wait until the file is unlocked. With flock (which is partially already implemented in the old versions) we have a file lock implementation. I would think that resolving LOG4PHP-71 resolves this issue too. Other file locking than flock seems odd to me. flock does support LOCK_NB mode, but this will not work on windows. Before having a not portable feature, I would think: leave it out, use flock to lock to manage mostly "nonblocking" writes and don't care, if other processes open the file. PLease see: http://blog.grobmeier.de/2009/08/21/performance-ofnonblocking-write-to-files-via-php.html
          Hide
          Knut Urdalen added a comment -

          We have raised this discussion as part of another thread before without deciding whether or not we want to add file locking to file appenders.

          log4j does not have this and I have never seen corrupt log messages because of such race condition, however it sounds reasonable to add file locking for file appenders.

          The main issue is what should an appender do if the file is locked by another process? Should it skip logging or should it wait for unlock?

          I guess file locking also have a very tiny performance decrease because it need to do another system call.

          Show
          Knut Urdalen added a comment - We have raised this discussion as part of another thread before without deciding whether or not we want to add file locking to file appenders. log4j does not have this and I have never seen corrupt log messages because of such race condition, however it sounds reasonable to add file locking for file appenders. The main issue is what should an appender do if the file is locked by another process? Should it skip logging or should it wait for unlock? I guess file locking also have a very tiny performance decrease because it need to do another system call.

            People

            • Assignee:
              Knut Urdalen
              Reporter:
              Knut Urdalen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development