Le 10/07/2010 08:02, Mike Schilli a écrit :
> 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.

Hi Mike,

[also sorry for the delay]

Thank you for the hint. I'm not sure how to put the configuration for the 
temporary appender in the general configuration file: because the temporary 
file appender needs to get created during the execution in a temporary 
directory (that gets created itself during execution). Whereas if the 
configuration for the temporary file appender is in the general configuration 
file, then the temporary log file seems to get created in the beginning... 
leading to an error because of the missing temporary directory...

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

That's the expected behaviour, but the code snippets comes from a single 
script, so there should not be any other reference to the temporary appender. 
And what I could observe under NFS is that the appender *somehow* keeps the 
filehandle open. I just wanted to warn about this "somehow" (probably related 
to "NFS silly renames" ?), and maybe learn how to deal with it.

Best,
Foudil



------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to