Re: [log4perl-devel] Why is Log::Log4perl opening unreferenced log files and can I stop it
Kevin Goess wrote: > Martin, see 'perldoc Log4perl::Appender::File > > create_at_logtime > The file appender typically creates its logfile in its constructor, i.e. > at Log4perl "init()" time. This > is desirable for most use cases, because it makes sure that file > permission problems get detected right > away, and not after days/weeks/months of operation when the appender > suddenly needs to log something and > fails because of a problem that was obvious at startup. > > However, there are rare use cases where the file shouldn’t be created at > Log4perl "init()" time, e.g. if > the appender can’t be used by the current user although it is defined in > the configuration file. If you > set "create_at_logtime" to a true value, the file appender will try to > create the file at log time. Note > that this setting lets permission problems sit undetected until log > time, which might be undesirable. Kevin, Thanks for pointing that out although I guess I missed this because I was using Log::Dispatch::File (which does not have create_at_log) and not Log::Log4perl::Appender::File. When I change to Log::Log4perl::Appender::File and set the create_at_log it works fine. Martin -- Martin J. Evans Easysoft Limited http://www.easysoft.com > > > Martin J. Evans wrote: >> Hi, >> >> I have a number of daemon processes using Log::Log4perl and tens of >> modules shared between them also using Log::Log4perl. All the log4perl >> configuration is in a single file for convenience (as most modules in it >> are common). Each perl module has its own log entry and logs to a >> different file. The problem is there are ALOT of different log files >> defined and Log4perl seems to open every file mentioned in the config >> file even though only a handful might be used. e.g., >> >> config: >> log4perl.logger.XXX.module1 = INFO, MONE >> log4perl.appender.MONE=Log::Dispatch::File >> log4perl.appender.MONE.filename=/tmp/file1.log >> >> log4perl.logger.XXX.module2 = INFO, MTWO >> log4perl.appender.MTWO=Log::Dispatch::File >> log4perl.appender.MTWO.filename=/tmp/file2.log >> . >> . >> . >> etc >> >> and daemon1 uses module XXX::module1 but not XXX.module2, the >> /tmp/file2.log is opened in daemon1 even though it is never going to be >> logged to. This is rather annoying since it is using up my open file >> descriptors etc. >> >> Using lsof on a single daemon shows dozens of log files open even though >> there is NO chance it will log anything to them. >> >> Is there any way to stop this? >> >> Thanks. >> >> Martin >> > -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel
Re: [log4perl-devel] Why is Log::Log4perl opening unreferenced log files and can I stop it
Martin, see 'perldoc Log4perl::Appender::File create_at_logtime The file appender typically creates its logfile in its constructor, i.e. at Log4perl "init()" time. This is desirable for most use cases, because it makes sure that file permission problems get detected right away, and not after days/weeks/months of operation when the appender suddenly needs to log something and fails because of a problem that was obvious at startup. However, there are rare use cases where the file shouldn’t be created at Log4perl "init()" time, e.g. if the appender can’t be used by the current user although it is defined in the configuration file. If you set "create_at_logtime" to a true value, the file appender will try to create the file at log time. Note that this setting lets permission problems sit undetected until log time, which might be undesirable. Martin J. Evans wrote: > Hi, > > I have a number of daemon processes using Log::Log4perl and tens of > modules shared between them also using Log::Log4perl. All the log4perl > configuration is in a single file for convenience (as most modules in it > are common). Each perl module has its own log entry and logs to a > different file. The problem is there are ALOT of different log files > defined and Log4perl seems to open every file mentioned in the config > file even though only a handful might be used. e.g., > > config: > log4perl.logger.XXX.module1 = INFO, MONE > log4perl.appender.MONE=Log::Dispatch::File > log4perl.appender.MONE.filename=/tmp/file1.log > > log4perl.logger.XXX.module2 = INFO, MTWO > log4perl.appender.MTWO=Log::Dispatch::File > log4perl.appender.MTWO.filename=/tmp/file2.log > . > . > . > etc > > and daemon1 uses module XXX::module1 but not XXX.module2, the > /tmp/file2.log is opened in daemon1 even though it is never going to be > logged to. This is rather annoying since it is using up my open file > descriptors etc. > > Using lsof on a single daemon shows dozens of log files open even though > there is NO chance it will log anything to them. > > Is there any way to stop this? > > Thanks. > > Martin > -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel
[log4perl-devel] Why is Log::Log4perl opening unreferenced log files and can I stop it
Hi, I have a number of daemon processes using Log::Log4perl and tens of modules shared between them also using Log::Log4perl. All the log4perl configuration is in a single file for convenience (as most modules in it are common). Each perl module has its own log entry and logs to a different file. The problem is there are ALOT of different log files defined and Log4perl seems to open every file mentioned in the config file even though only a handful might be used. e.g., config: log4perl.logger.XXX.module1 = INFO, MONE log4perl.appender.MONE=Log::Dispatch::File log4perl.appender.MONE.filename=/tmp/file1.log log4perl.logger.XXX.module2 = INFO, MTWO log4perl.appender.MTWO=Log::Dispatch::File log4perl.appender.MTWO.filename=/tmp/file2.log . . . etc and daemon1 uses module XXX::module1 but not XXX.module2, the /tmp/file2.log is opened in daemon1 even though it is never going to be logged to. This is rather annoying since it is using up my open file descriptors etc. Using lsof on a single daemon shows dozens of log files open even though there is NO chance it will log anything to them. Is there any way to stop this? Thanks. Martin -- Martin J. Evans Easysoft Limited http://www.easysoft.com -- This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first ___ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel