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?

That's intentional. If Log4perl can't open a file associated with a file
appender, it dies. This might seem drastic, but if a logging system
can't log its errors, it's the safest thing do abort and let the user
know. If you don't like it, you can catch the error via eval {} around
init, but I wouldn't recommend doing that.

You can resolve the problem by making sure permissions are ok. This can
be done by using different logfiles for different users, setting group
permissions (umask parameter in the file appender) or switching to
a syslog appender.

-- Mike

Mike Schilli
[EMAIL PROTECTED]

-------------------------------------------------------------------------
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