From: Mike S. <m...@pe...> - 2005-09-10 21:18:23
|
On Fri, 9 Sep 2005, Chris Anderson wrote: > It looks rather simple to filter based on a level, however with each > child dynamically needing a different filename while main initializes > I'm not clear on how the filter would need to be setup. Alternatively, you could have the child change its appender file: use Log::Log4perl qw(:easy); my $conf = q( log4perl.category = DEBUG, Logfile log4perl.appender.Logfile = Log::Log4perl::Appender::File log4perl.appender.Logfile.filename = test.log log4perl.appender.Logfile.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.Logfile.layout.ConversionPattern = %d %F{1} %L> %m %n ); Log::Log4perl->init(\$conf); for(1..3) { my $pid = fork(); die "Can't fork" unless defined $pid; if($pid == 0) { # Child, switch appender file to test.log.PID my $app = Log::Log4perl->appender_by_name("Logfile"); my $old = $app->filename(); $app->file_switch($app->filename() . ".$$"); DEBUG "Child $$"; sleep (3); exit; } } print "parent\n"; wait() for (1..5); print "Done.\n"; -- Mike Mike Schilli m...@pe... |