|
From: <jsc...@gm...> - 2007-03-09 21:52:59
|
Hello!
the problem:
I want to execute a number of different perl scripts (named 1.pl..10.pl in the
code below) .
every executed file should be logged to a corresponding logfile (1.log ..
10.log)
I want to have the same layout for the log in the files as on the screen
and want to configure all with a configuration file for log4perl
(in the code below its done in a string instead)
what is the recommended way to change the name of the logfiles in runtime?
I experimented a little with
add_appender and remove_appender under runtime
what's with file_switch($new_file_log);
how can I use this?
thanks for some explanations or even better some code examples!
thank you for help
Juergen
here the frame code:
#!/usr/bin/perl
use warnings;
use strict;
use Log::Log4perl qw(get_logger);
# Define configuration
my $conf = q(
log4perl.logger = ERROR, FileApp, ScreenApp
log4perl.appender.FileApp = Log::Log4perl::Appender::File
log4perl.appender.FileApp.filename = test.log
log4perl.appender.FileApp.layout = PatternLayout
log4perl.appender.FileApp.layout.ConversionPattern = %d> %m%n
log4perl.appender.ScreenApp = Log::Log4perl::Appender::Screen
log4perl.appender.ScreenApp.layout = PatternLayout
log4perl.appender.ScreenApp.layout.ConversionPattern = %d> %m%n
);
# Initialize logging behaviour
Log::Log4perl->init( \$conf );
# Obtain a logger instance
my $logger = get_logger("test");
foreach my $new_file (1..10) {
$new_file_log .= '.log';
#
# do '$new_file'.'.pl';
#
}
|