From: Mike S. <m...@pe...> - 2007-07-12 17:24:48
|
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 m...@pe... |