Re: [log4perl-devel] eradicate / NFS

2010-07-09 Thread Mike Schilli
On Tue, 6 Jul 2010, Foudil wrote:

> In order to log to a tmp directory (that we want to remove later), we
> create an appender in a script that we add to our project's loggers:
> Log::Log4perl->init_and_watch($path_conf."/log.conf", 'HUP');

Hi Foudil,

sorry for the long wait. I've noticed that you're using init_and_watch()
along with user-defined appenders. Just a heads-up that this can lead to
unpredictable situations: Whenever Log4perl/init_and_watch() notices
that it needs to reload the configuration file (because it has changed),
you'll lose the temporary appender, because the Log4perl configuration
will be overwritten.

Even if you don't need the appender permanently, it makes sense to have
it in the configuration, if only for reasons of clarity.

>Log::Log4perl->eradicate_appender($local_appender_name);
># ...but the appender is still alive and keeps filehandles open. So we need
>#  to close them explicitly.

The eradicate_appender() method should take are of the issue in this
situation. Only exception: if still have references to the appender 
anywhere in your application code, the appender destructor won't run and
you need to run file_close() manually.

Hope that helps!

-- Mike

Mike Schilli
[email protected]

--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] printf-like messages

2010-07-09 Thread Mike Schilli

On Thu, 8 Jul 2010, Tomáš Nechutný wrote:


I can live without it (and use sprintf() return value as a parameter
to log methods), but it would be nice.


Yeah, sprintf() should take care of all your formatting needs. I've
found that I use printf() very rarely in Perl, because you can
interpolate variables so elegantly in strings. Also, there's a lot of
hidden functionality in the loggers as is (think about loggers that take
fixed arguments like database loggers, or that you can pass a subroutine
to any logger which it will then evaluate), so having printf-like
functions would considerably complicate things. But thanks for the
suggestion!

-- Mike

Mike Schilli
[email protected]
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel