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 "Knut Urdalen (JIRA)" <ji...@apache.org> on 2009/04/28 18:15:30 UTC

[jira] Commented: (LOG4PHP-26) Add file locking to file appenders

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

Knut Urdalen commented on LOG4PHP-26:
-------------------------------------

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.



> Add file locking to file appenders
> ----------------------------------
>
>                 Key: LOG4PHP-26
>                 URL: https://issues.apache.org/jira/browse/LOG4PHP-26
>             Project: Log4php
>          Issue Type: New Feature
>          Components: Code
>            Reporter: Knut Urdalen
>            Assignee: Knut Urdalen
>             Fix For: 2.0
>
>
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Commented: (LOG4PHP-26) Add file locking to file appenders

Posted by Christian Grobmeier <gr...@gmail.com>.
>> Uhm, what happens if I actually wan't different php processes to log to
>> the same file?
>> I'm pretty sure I have done this at some point in Java.

In PHP you do this with very hi chances. I think on high load servers
which open multiple php processes and write to the same logfile.

> File locking should only ensure that your log file doesn't include corrupt
> log messages due to race condition between two or more PHP processes logging
> to the same file at the same time.
>
> It should be fine to log to the same file from different PHP processes (we
> don't want to limit that possibility).

Actually, we cannot limit this possiblity.
Anyway, after reading a bit I think file locking is necessary. If a
process cannot have the file lock, it should wait till it can.

Cheers
Christian

>
> Knut
>
>

Re: [jira] Commented: (LOG4PHP-26) Add file locking to file appenders

Posted by Knut Urdalen <kn...@php.no>.
Dennis Korbar wrote:
> Uhm, what happens if I actually wan't different php processes to log 
> to the same file?
> I'm pretty sure I have done this at some point in Java.
File locking should only ensure that your log file doesn't include 
corrupt log messages due to race condition between two or more PHP 
processes logging to the same file at the same time.

It should be fine to log to the same file from different PHP processes 
(we don't want to limit that possibility).

Knut


Re: [jira] Commented: (LOG4PHP-26) Add file locking to file appenders

Posted by Dennis Korbar <de...@googlemail.com>.
Uhm, what happens if I actually wan't different php processes to log to the
same file?
I'm pretty sure I have done this at some point in Java.

2009/4/28 Knut Urdalen (JIRA) <ji...@apache.org>

>
>    [
> https://issues.apache.org/jira/browse/LOG4PHP-26?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12703698#action_12703698]
>
> Knut Urdalen commented on LOG4PHP-26:
> -------------------------------------
>
> 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.
>
>
>
> > Add file locking to file appenders
> > ----------------------------------
> >
> >                 Key: LOG4PHP-26
> >                 URL: https://issues.apache.org/jira/browse/LOG4PHP-26
> >             Project: Log4php
> >          Issue Type: New Feature
> >          Components: Code
> >            Reporter: Knut Urdalen
> >            Assignee: Knut Urdalen
> >             Fix For: 2.0
> >
> >
> > 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.
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>