>>>>> "Mike" == Mike Schilli <[EMAIL PROTECTED]> writes:

    Mike> On Thu, 12 Jul 2007, Michael Schmitz wrote:

    >> I have a configuration file that defines a number of
    >> loggers. All of them use a file-appender. As the configuration
    >> file is used by different applications running under different
    >> accounts (root and unprivileged accounts), not all files are
    >> writable by for all applications.
    >> 
    >> When an unprivileged user starts an application,
    >> Log::Log4perl->init() fails, because the user does not have
    >> write permission on at least one of the log files:
    >> 
    >> Can't open /home/mls/tmp/test/root-lf.log (Permission denied)
    >> at /usr/lib/perl5/site_perl/5.8.8/Log/Log4perl/Appender/File.pm
    >> line 97.
    >> 
    >> As this happens in initialization, the application doesn't even
    >> come to the point where it obtains its own logger.
    >> 
    >> Is this behaviour intentional in log4perl v1.12 or is it a bug?

    Mike> That's intentional. If Log4perl can't open a file associated
    Mike> with a file appender, it dies. This might seem drastic, but
    Mike> if a logging system can't log its errors, it's the safest
    Mike> thing do abort and let the user know.

This is in fact a drastic approach. As regards problems that prevent
proper logging, I agree with you, but this is not the case for
me.

Different application running with different privileges share a common
configuration file. It would be a problem if an unprivileged
application uses a logger that logs to a file the user cannot write
to, but this is not the case. As long as the application attempts to
use the correct logger (which is the case), ie. the one it is meant to
use, and this logger is associated with a file the unprivileged user
can write to, it is fine from my point of view.

If log4perl would check for the appropriate permission when an
application creates the logger, it could (and it should) let the user
know. Checking in the initialization phase anticipates problems that
may not even occur.

    Mike> If you don't like it, you can catch the error via eval {}
    Mike> around init, but I wouldn't recommend doing that.

Yes I will have to do this, but this is only part of the truth, as I
will have to check for write permission when obtaining the logger.

Michael.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to