|
From: Mike S. <m...@pe...> - 2007-03-09 22:06:42
|
On Fri, 9 Mar 2007, [iso-8859-1] J=FCrgen Sch=F6neberg wrote:
> the problem:
>
> I want to execute a number of different perl scripts (named
> 1.pl..10.pl in the code below) .
Just use a subroutine in your Log4perl configuration:
log4perl.appender.FileApp.filename =3D sub { "$0.log" }
This will even work if you stuff your l4p configuration into a config
file.
-- Mike
Mike Schilli
m...@pe...
>
> 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 =3D q(
> log4perl.logger =3D ERROR, FileApp, ScreenApp
> log4perl.appender.FileApp =3D Log::Log4perl::Appender::File
> log4perl.appender.FileApp.filename =3D test.log
> log4perl.appender.FileApp.layout =3D PatternLayout
> log4perl.appender.FileApp.layout.ConversionPattern =3D %d> %m%n
>
> log4perl.appender.ScreenApp =3D Log::Log4perl::Appender::Scr=
een
> log4perl.appender.ScreenApp.layout =3D PatternLayout
> log4perl.appender.ScreenApp.layout.ConversionPattern =3D %d> %m%n
>
>
> );
>
> # Initialize logging behaviour
> Log::Log4perl->init( \$conf );
>
> # Obtain a logger instance
> my $logger =3D get_logger("test");
>
>
> foreach my $new_file (1..10) {
>
> $new_file_log .=3D '.log';
>
> #
> # do '$new_file'.'.pl';
> #
>
> }
>
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share y=
our
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D=
DEVDEV
> _______________________________________________
> log4perl-devel mailing list
> log...@li...
> https://lists.sourceforge.net/lists/listinfo/log4perl-devel
>
|