Hi,
 
I am new to this list and hope this is the right place for my questions.

I am using Log4perl in a server project with parent and child processes.
And it's great, of course  ;-) 
Due to an initialization of log4perl that has multiple steps I recently
switched from text based initialization to API calls.
 
Three problems occured:
 
1) The sub Log::Log4perl::Appender::Synchronized->post_init() is not
called when the appender is created via API.
Is this correct?
My way to handle this was to write an own class derived from
Synchronized an copy the code from post_init() to new().

 
2) How to correctly configure a composite appender via API?
Concrete: How to create an appender which is not connected to any logger
and register it in a composite appender?
(It seems that there is no alternative to the code used in
Log::Log4perl::Config->create_appender_instance(), line 402)
 
Following code works, but results in double log entries in the file:
 
my $fileApp = Log::Log4perl::Appender->new(
   'Log::Log4perl::Appender::File',
   name     => 'MyFileApp',
   filename => '/tmp/mylog',
   mode     => 'append',
   syswrite => 1,
);
$fileApp->layout(
   Log::Log4perl::Layout::PatternLayout::Multiline->new('%d{yyyy-MM-dd
HH:mm:ss} %p [%c] #%P> %m%n')
);
$this->logger->get_root_logger()->add_appender($fileApp);
 
my $syncApp = Log::Log4perl::Appender->new(
   'Log::Log4perl::Appender::Synchronized',
   name       => 'MySyncApp',
   appender   => 'MyFileApp',
   key        => 'nem',
);
$this->logger->get_root_logger()->add_appender($syncApp);


3) When initialising Log::Log4perl::Appender::Synchronized before
forking child processes, eventually all existing processes try to remove
the semaphore.
I could only solve this with a derived class that stores the process id
of the parent and only allowed the parent to remove the semaphore.
 
 
I'm struggling with these problems for 4 days now and would appreciate
any answer!
But for the time being: I wish you a very Happy Easter!
 
Regards,
Jens Berthold



------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to