You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(38) |
Sep
(126) |
Oct
(23) |
Nov
(72) |
Dec
(36) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(76) |
Feb
(32) |
Mar
(19) |
Apr
(6) |
May
(54) |
Jun
(40) |
Jul
(45) |
Aug
(35) |
Sep
(51) |
Oct
(67) |
Nov
(10) |
Dec
(50) |
2004 |
Jan
(51) |
Feb
(22) |
Mar
(22) |
Apr
(28) |
May
(53) |
Jun
(99) |
Jul
(38) |
Aug
(49) |
Sep
(23) |
Oct
(29) |
Nov
(30) |
Dec
(48) |
2005 |
Jan
(15) |
Feb
(21) |
Mar
(25) |
Apr
(16) |
May
(131) |
Jun
|
Jul
(8) |
Aug
(5) |
Sep
(15) |
Oct
|
Nov
(15) |
Dec
(12) |
2006 |
Jan
(15) |
Feb
(20) |
Mar
(8) |
Apr
(10) |
May
(3) |
Jun
(16) |
Jul
(15) |
Aug
(11) |
Sep
(17) |
Oct
(27) |
Nov
(11) |
Dec
(12) |
2007 |
Jan
(19) |
Feb
(18) |
Mar
(33) |
Apr
(4) |
May
(15) |
Jun
(22) |
Jul
(19) |
Aug
(20) |
Sep
(14) |
Oct
(4) |
Nov
(34) |
Dec
(11) |
2008 |
Jan
(8) |
Feb
(18) |
Mar
(2) |
Apr
(4) |
May
(26) |
Jun
(9) |
Jul
(8) |
Aug
(8) |
Sep
(3) |
Oct
(17) |
Nov
(14) |
Dec
(4) |
2009 |
Jan
(6) |
Feb
(41) |
Mar
(21) |
Apr
(10) |
May
(21) |
Jun
|
Jul
(8) |
Aug
(4) |
Sep
(3) |
Oct
(8) |
Nov
(6) |
Dec
(5) |
2010 |
Jan
(14) |
Feb
(13) |
Mar
(7) |
Apr
(12) |
May
(4) |
Jun
(1) |
Jul
(11) |
Aug
(5) |
Sep
|
Oct
(1) |
Nov
(10) |
Dec
|
2011 |
Jan
(7) |
Feb
(3) |
Mar
(1) |
Apr
(5) |
May
|
Jun
(1) |
Jul
(6) |
Aug
(6) |
Sep
(10) |
Oct
(5) |
Nov
(4) |
Dec
(5) |
2012 |
Jan
(4) |
Feb
(5) |
Mar
(1) |
Apr
(7) |
May
(1) |
Jun
|
Jul
(2) |
Aug
|
Sep
(5) |
Oct
(5) |
Nov
(4) |
Dec
(5) |
2013 |
Jan
(6) |
Feb
|
Mar
(14) |
Apr
(9) |
May
(3) |
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
(4) |
Dec
(6) |
2014 |
Jan
|
Feb
(1) |
Mar
(10) |
Apr
|
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(4) |
Oct
(1) |
Nov
|
Dec
(4) |
2015 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Mike S. <m...@pe...> - 2007-03-18 07:17:02
|
On Sat, 17 Mar 2007, [iso-8859-1] J=FCrgen Sch=F6neberg wrote: > - I just wonder about the usage of the levels: > I have a sript including user interations: > usual 'print' to the user and > $in =3D <STDIN>; for user input > I also want to log this interactions. > but none of the Log4perl log levels seems to be > appropriate for this. > (of course I could use a custom level e.g $logger->print()) > but shouldn't this be included in Log4perl by default? > (with highest log priority , higher than level FATAL?) If you want a priority level that's higher than FATAL, there is one: "OFF". This strange name comes from the fact that Log4perl sets levels as hurdles to block messages and the level "OFF" blocks even FATAL messages. On the flip side, a message with priority "OFF" will pass any hurdle, even levels "FATAL" and "OFF". So is this what you are looking for? use Log::Log4perl qw(get_logger); my $logger =3D get_logger(); $logger->off("This message is unstoppable"); -- Mike Mike Schilli m...@pe... |
From: Mike S. <m...@pe...> - 2007-03-18 06:46:07
|
On Fri, 16 Mar 2007, Withers John Z wrote: > I've encountered what appear to be bugs in Log::Log4perl::JavaMap/* > (version 1.09). > > When the property file includes: > > log4j.appender.APPLOG = or.apache.log4j.ConsoleAppender > > My PERL script fails because Log/Dispatch/Screen.pm can't be located. > It isn't included with the distribution. It appears that > Log::Log4perl::JavaMap::ConsoleAppender.pm (and others) maps the > property value to the wrong class. > Log::Log4perl::JavaMap::ConsoleAppender->new tries to map to > Log::Dispatch::Screen when it probably should map to > Log::Log4perl::Appender::Screen. Hi John, the JavaMap ConsoleAppender dates back to the days when Log4perl didn't have its own screen appender, so it uses Log::Dispatch::Screen. It doesn't come with the Log4perl distribution, but it can be downloaded from CPAN: http://search.cpan.org/~drolsky/Log-Dispatch-2.16/lib/Log/Dispatch.pm Of course, you could just use Log::Log4perl::Appender::Screen directly, any particular reason why you're using the JavaMap? Not that there's anything wrong with it, I'm just curious. -- Mike Mike Schilli m...@pe... |
From: Mike S. <m...@pe...> - 2007-03-18 06:41:14
|
On Fri, 9 Mar 2007, Dietmar Fiehn, Dr. wrote: > I am thinking about usingLog4Perl in my apps. I tried to start > with a simple app just to get a feeling and I got some weird > messages like > > Subroutine import redefined at > C:/home/df/bop2/perl_MSWIN32/site/lib/Log/Log4Perl.pm line 69. This is very strange, it looks like the installation is broken. Here's instructions for installing Log4perl on Windows: http://log4perl.sourceforge.net/d/Log/Log4perl/FAQ.html#f7dc3 -- Mike Mike Schilli m...@pe... |
From: <jsc...@gm...> - 2007-03-17 19:25:04
|
Hello! Log4perl is working fine for me.=20 =2D I just wonder about the usage of the levels: I have a sript including user interations: usual 'print' to the user and $in =3D <STDIN>; for user input I also want to log this interactions. but none of the Log4perl log levels seems to be=20 appropriate for this. (of course I could use a custom level e.g $logger->print()) but shouldn't this be included in Log4perl by default? (with highest log priority , higher than level FATAL?) or do I have do bind the normal 'print' to $logger->print ? Thanks for ideas J=FCrgen |
From: Mike S. <m...@pe...> - 2007-03-17 07:02:12
|
On Thu, 15 Mar 2007, Daniel Lo wrote: > I was using log4perl, when I discovered that a small mistake I had made > did not generate any error message. I had made a mistake in the directory > naming. I found that log4perl will not express an warning or error, when a > package is declared that does not exist and there are other > categories to choose from. Hi Daniel, thanks for reporting this issue! Actually, the error is in the line log4perl.opps = DEBUG, NoExist which probably was meant to be log4perl.logger.opps = DEBUG, NoExist in which case the error with the non-existing appender class would have been reported. The way the configuration was coded, log4perl.opps = DEBUG, NoExist it defined an undefined (but maybe future :) keyword 'opps' which was ignored by Log4perl. The Appender definition # Non Existant Appender log4perl.appender.NoExist = Log::Log4perl::Appender::NoExist log4perl.appender.NoExist.layout = PatternLayout log4perl.appender.NoExist.layout.ConversionPattern = %m%n ); also was ignored because no logger was actually using it. Some day we're gonna rework the PropertyConfigurator to insist on a fixed set of keywords, make sure that there are no dangling parts and add better sanity checks. Really :) -- Mike Mike Schilli m...@pe... > > > Below is a test script that expresses this problem. > > > > Thank you for your time, > > > -daniel > > ----------------------------------------------------------------------- > > use warnings; > use strict; > > use Log::Log4perl qw(get_logger); > use Test::More tests => 2; > > # appender NoExist does not exist, and should generate some sort of error > # message > my $conf = qq( > log4perl.rootLogger = DEBUG, buffer > log4perl.opps = DEBUG, NoExist > > # Regular Screen Appender > log4perl.appender.buffer = Log::Log4perl::Appender::TestBuffer > log4perl.appender.buffer.layout = PatternLayout > log4perl.appender.buffer.layout.ConversionPattern = %m%n > > # Non Existant Appender > log4perl.appender.NoExist = Log::Log4perl::Appender::NoExist > log4perl.appender.NoExist.layout = PatternLayout > log4perl.appender.NoExist.layout.ConversionPattern = %m%n > ); > > eval { > Log::Log4perl->init(\$conf); > }; > ok(length($@) > 0, "This should contain an error message: $@"); > > # no error message from: Log::Log4perl::Appender::NoExist > diag("\$@=$@\n"); > > my $badLogger = get_logger('opps'); > $badLogger->info('How can you log to an non-existant package?'); > > my $buffer = Log::Log4perl::Appender::TestBuffer->by_name('buffer'); > > is ($buffer->buffer,"","buffer is empty!"); > diag("buffer contains: " . $buffer->buffer); > > > |
From: Mike S. <m...@pe...> - 2007-03-17 06:58:06
|
---------- Forwarded message ---------- From: Daniel Lo <dan...@pi...> To: Michael Schilli <m...@pe...> Subject: Log4perl doesn't express an error with multiple categories and a non existent package. Date: Thu, 15 Mar 2007 11:13:04 -0700 Mr. Schilli, I was using log4perl, when I discovered that a small mistake I had made did not generate any error message. I had made a mistake in the directory naming. I found that log4perl will not express an warning or error, when a package is declared that does not exist and there are other categories to choose from. Below is a test script that expresses this problem. Thank you for your time, -daniel ----------------------------------------------------------------------- use warnings; use strict; use Log::Log4perl qw(get_logger); use Test::More tests => 2; # appender NoExist does not exist, and should generate some sort of error # message my $conf = qq( log4perl.rootLogger = DEBUG, buffer log4perl.opps = DEBUG, NoExist # Regular Screen Appender log4perl.appender.buffer = Log::Log4perl::Appender::TestBuffer log4perl.appender.buffer.layout = PatternLayout log4perl.appender.buffer.layout.ConversionPattern = %m%n # Non Existant Appender log4perl.appender.NoExist = Log::Log4perl::Appender::NoExist log4perl.appender.NoExist.layout = PatternLayout log4perl.appender.NoExist.layout.ConversionPattern = %m%n ); eval { Log::Log4perl->init(\$conf); }; ok(length($@) > 0, "This should contain an error message: $@"); # no error message from: Log::Log4perl::Appender::NoExist diag("\$@=$@\n"); my $badLogger = get_logger('opps'); $badLogger->info('How can you log to an non-existant package?'); my $buffer = Log::Log4perl::Appender::TestBuffer->by_name('buffer'); is ($buffer->buffer,"","buffer is empty!"); diag("buffer contains: " . $buffer->buffer); |
From: Mike S. <m...@pe...> - 2007-03-15 07:23:29
|
On Tue, 13 Mar 2007, Kevin M. Goess wrote: > Hey, Mike, per the note I just sent to Robert Jacobson, it looks like > the implementation of triggers doesn't match the docs. Good catch, thanks for the fix! > Attached is a quick fix that will produce the desired behavior. I > haven't fixed the docs in Buffer.pm. And is there a better way to do > priority comparisons than what I put in the test? Sorry, I'm in a > hurry, I'll try to look at it more tonight. If you use use Log::Log4perl::Level; then the $DEBUG, $INFO, etc. constants are exported into the main namespace and Log::Log4perl::Level::to_priority('ERROR') can be written as $ERROR but that's about it I think, and normally this kind of trigger would be written as log4perl.appender.Buffer.trigger_level = ERROR anyway ;). Thanks again! -- Mike Mike Schilli m...@pe... |
From: Robert J. <yad...@sn...> - 2007-03-14 12:49:41
|
At 04:01 PM 3/13/2007, Kevin M. Goess wrote: >I thought this would be a quick, easy answer, but there's actually a >couple things going on: [snip] Thanks for the explanation! At least now I have a workaround :) > 1) since you're using qq() to enclose the string containing your >config, [snip] It's in the docs that way. I guess the doc also needs to be updated. BTW, should the Buffer appender flush its buffer on DESTROY? It seems like when the script ends any messages still in the buffer are lost. I suppose this is the case for *any* trigger sub that doesn't always return true? -- Rob |
From: Kevin M. G. <cp...@go...> - 2007-03-13 22:22:01
|
Hey, Mike, per the note I just sent to Robert Jacobson, it looks like the implementation of triggers doesn't match the docs. Something like this actually gets compiled and run when the config is loaded, but we just want it compiled, it shouldn't be run until the trigger is called: log4perl.appender.Buffer.trigger = sub {return 99}; That results in Buffer.trigger being assigned a value of 99, instead of a CODE(x123123) ref. Attached is a quick fix that will produce the desired behavior. I haven't fixed the docs in Buffer.pm. And is there a better way to do priority comparisons than what I put in the test? Sorry, I'm in a hurry, I'll try to look at it more tonight. What do you think? -- Happy Trails . . . Kevin M. Goess |
From: Kevin M. G. <cp...@go...> - 2007-03-13 21:01:59
|
I thought this would be a quick, easy answer, but there's actually a couple things going on: 1) since you're using qq() to enclose the string containing your config, all the $'s and \'s are being interpolated by perl when the script loads. Use q() instead--it's like single quotes around a string, so there is no interpolation. 2) It looks like the docs for trigger are just a little bit wrong. To get the desired behavior, you currently have to wrap your sub in another sub, like this: log4perl.appender.Buffer.trigger = sub { sub{return 1} } I'll propose a fix to Mike in a separate note to the list. 3) The comparison inside the trigger also won't work the way the docs are written. You'll need something like this, which is inherently inefficient and uses some internal functions, but it's a quick answer: log4perl.appender.Buffer.trigger = sub { \ my($self, $params) = @_; \ return \ Log::Log4perl::Level::to_priority($params->{log4p_level}) \ >= \ Log::Log4perl::Level::to_priority('ERROR') } Robert Jacobson wrote: > I'm trying to use the "trigger" function of Buffer, but I can't seem > to get it to work. I just took the examples from the perldoc and > stuck them together: > > use Log::Log4perl qw(:easy); > > my $conf = qq( > log4perl.category = DEBUG, Buffer > > # Regular Screen Appender > log4perl.appender.Screen = Log::Log4perl::Appender::Screen > log4perl.appender.Screen.stdout = 1 > log4perl.appender.Screen.layout = PatternLayout > log4perl.appender.Screen.layout.ConversionPattern = %d %p %c %m %n > > # Buffering appender, using the appender above as outlet > log4perl.appender.Buffer = > Log::Log4perl::Appender::Buffer > log4perl.appender.Buffer.appender = Screen > log4perl.appender.Buffer.trigger = sub { \ > my($self, $params) = @_; \ > return $params->{log4p_level} >= \ > $Log::Log4perl::Level::ERROR; } > ); > > Log::Log4perl->init(\$conf); > > DEBUG("This message gets buffered."); > INFO("This message gets buffered also."); > > # Time passes. Nothing happens. But then ... > > print "It's GO time!!!\n"; > > ERROR("This message triggers a buffer flush."); > > > But when I run the above I get: > > Can't evaluate 'sub {' (Missing right curly or square bracket at > (eval 9) line 2, at end of line > syntax error at (eval 9) line 2, at EOF > ) at /opt/ActivePerl-5.8/lib/site_perl/5.8.7/Log/Log4perl/Config.pm line 741. > > > Even a simple "return 1" doesn't work, i.e.: > log4perl.appender.Buffer.trigger = sub {return 1;} > > Am I missing something simple? (again? :) ) > > > -- > Rob > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > log4perl-devel mailing list > log...@li... > https://lists.sourceforge.net/lists/listinfo/log4perl-devel |
From: Robert J. <yad...@sn...> - 2007-03-13 19:58:46
|
I'm trying to use the "trigger" function of Buffer, but I can't seem to get it to work. I just took the examples from the perldoc and stuck them together: use Log::Log4perl qw(:easy); my $conf = qq( log4perl.category = DEBUG, Buffer # Regular Screen Appender log4perl.appender.Screen = Log::Log4perl::Appender::Screen log4perl.appender.Screen.stdout = 1 log4perl.appender.Screen.layout = PatternLayout log4perl.appender.Screen.layout.ConversionPattern = %d %p %c %m %n # Buffering appender, using the appender above as outlet log4perl.appender.Buffer = Log::Log4perl::Appender::Buffer log4perl.appender.Buffer.appender = Screen log4perl.appender.Buffer.trigger = sub { \ my($self, $params) = @_; \ return $params->{log4p_level} >= \ $Log::Log4perl::Level::ERROR; } ); Log::Log4perl->init(\$conf); DEBUG("This message gets buffered."); INFO("This message gets buffered also."); # Time passes. Nothing happens. But then ... print "It's GO time!!!\n"; ERROR("This message triggers a buffer flush."); But when I run the above I get: Can't evaluate 'sub {' (Missing right curly or square bracket at (eval 9) line 2, at end of line syntax error at (eval 9) line 2, at EOF ) at /opt/ActivePerl-5.8/lib/site_perl/5.8.7/Log/Log4perl/Config.pm line 741. Even a simple "return 1" doesn't work, i.e.: log4perl.appender.Buffer.trigger = sub {return 1;} Am I missing something simple? (again? :) ) -- Rob |
From: Mike S. <m...@pe...> - 2007-03-10 23:33:17
|
On Sat, 10 Mar 2007, [iso-8859-1] J=FCrgen Sch=F6neberg wrote: > but I thought this solution with > perl.appender.FileApp.filename =3D sub { "$0.log" } > is just for defining a dynamic name for the log file at initialization ph= ase > of Log4perl (only once in the beginning of the perl script) > > but what I want to do is > - have one main script (called run.pl) with the Log4perl initialization (= only > here) > > - execute other scripts in a loop (1.pl ... 10.pl) from run.pl > (in these scripts I dont have a new Log4perl initialization ,(so no 'fil= ename > =3D sub { "$0.log" }' ) Ok, so I'm assuming you're "executing" scripts this way in your main program: for my $file (qw(t1 t2)) { require "$file.pl"; } which means they're running within the same process (if they were being run in different subprocesses, you would need to use a different logging approach altogether). And let's also assume that your main program initializes Log4perl like this: log4perl.category =3D DEBUG, Logfile log4perl.appender.Logfile =3D Log::Log4perl::Appender::File log4perl.appender.Logfile.filename =3D test.log log4perl.appender.Logfile.layout =3D Log::Log4perl::Layout::PatternLayout log4perl.appender.Logfile.layout.ConversionPattern =3D %m%n Specifics don't matter, just note that the name of the file appender you're using "Logfile". So if you want to have this file appender switch its log file every time you require/run one of your 'tN.pl' scripts, simply use my $app =3D Log::Log4perl->appender_by_name("Logfile"); for my $file (qw(t1 t2)) { $app->file_switch("$file.log"); require "$file.pl"; } and a script named "t1.pl" will log to "t1.log", while another script, named "t2.pl" will use "t2.log". Closer to what you were looking for? -- Mike Mike Schilli m...@pe... > > - I just want to start and write to a new logfile when I start a new scri= pt in > the loop > > - the scripts are using a old subroutine inside , Prints::print_log($text= ) > and I changed Prints::print_log($text) to > > package Prints; > sub print_log { > $logger->info(shift); > } > > the scripts I cant change (no log4perl statements inside them) > > so the change of the name for the logfile has to be done in the main scri= pt > run.pl > > so I added for every new script a new FileApp with the right logfile name= , > executed the script and removed the appender. This works, but I dont have= the > possibility > to configure the FileApp with the Log4perl configuration file because eve= ry > appender has a differnt name. > I have to do it inside the code of run.pl which is not so nice. > > > But I still wonder how to do this in the 'right and easy' way. > > or maybe > perl.appender.FileApp.filename =3D sub { "$0.log" } > was already the solution (I havent tried)?? > > Thanks for your help > J=FCrgen > > > > > > > > > > > > > > > > > > On Friday 09 March 2007 23:06, Mike Schilli wrote: > > 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.lo= g .. > > > 10.log) > > > > > > I want to have the same layout for the log in the files as on the scr= een > > > 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::F= ile > > > 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::Screen 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 sha= re > > > your opinions on IT & business topics through brief surveys-and earn = cash > > > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CI= D=3DDEVDEV > > > _______________________________________________ > > > log4perl-devel mailing list > > > log...@li... > > > https://lists.sourceforge.net/lists/listinfo/log4perl-devel > |
From: <jsc...@gm...> - 2007-03-10 22:17:25
|
Thanks for you fast answer! but I dont understand. I have read the FAQ : 'What if I need dynamic values in a static Log4perl=20 configuration file?' but I thought this solution with=20 perl.appender.FileApp.filename =3D sub { "$0.log" } is just for defining a dynamic name for the log file at initialization phas= e=20 of Log4perl (only once in the beginning of the perl script) but what I want to do is=20 =2D have one main script (called run.pl) with the Log4perl initialization (= only=20 here) =2D execute other scripts in a loop (1.pl ... 10.pl) from run.pl (in these scripts I dont have a new Log4perl initialization ,(so no 'filen= ame=20 =3D sub { "$0.log" }' ) =2D I just want to start and write to a new logfile when I start a new scri= pt in=20 the loop =2D the scripts are using a old subroutine inside , Prints::print_log($text) and I changed Prints::print_log($text) to =20 package Prints; sub print_log { $logger->info(shift); } the scripts I cant change (no log4perl statements inside them) so the change of the name for the logfile has to be done in the main script= =20 run.pl so I added for every new script a new FileApp with the right logfile name,= =20 executed the script and removed the appender. This works, but I dont have t= he=20 possibility to configure the FileApp with the Log4perl configuration file because every= =20 appender has a differnt name. I have to do it inside the code of run.pl which is not so nice. But I still wonder how to do this in the 'right and easy' way. or maybe=20 perl.appender.FileApp.filename =3D sub { "$0.log" } was already the solution (I havent tried)?? Thanks for your help J=FCrgen On Friday 09 March 2007 23:06, Mike Schilli wrote: > 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 = =2E. > > 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::Screen 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'; > > # > > > > } > > > > > > > > -----------------------------------------------------------------------= =2D- > > Take Surveys. Earn Cash. Influence the Future of IT > > Join SourceForge.net's Techsay panel and you'll get the chance to share > > your opinions on IT & business topics through brief surveys-and earn ca= sh > > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID= =3DDEVDEV > > _______________________________________________ > > log4perl-devel mailing list > > log...@li... > > https://lists.sourceforge.net/lists/listinfo/log4perl-devel |
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 > |
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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WFzIHdoYXQgaGFwcGVucz8gDQogDQpEaWV0bWFyDQo= |
From: Mike S. <m...@pe...> - 2007-03-07 06:45:04
|
On Tue, 6 Mar 2007, Lev Lvovsky wrote: > Hello, a co-worker has asked why the following snipped doesn't work > as imagined: > use strict; > use Log::Log4perl qw(:easy); > > Log::Log4perl->easy_init( > { level => $WARN, file => "STDOUT" }, > { level => $INFO, file => ">>info.log" } > ); > > INFO "This is info - should appear on STDOUT"; > > his thinking, is that this should not print anything to STDOUT, but > rather to info.log, given that STDOUT is reserved for WARN and > above. He pointed out the following in the documentation: > > "As shown above, easy_init() will take any number of different logger > definitions as hash references." It's correct that easy_init() will take any number of different logger definitions as hash references. But your co-worker fell into the trap explained here: http://log4perl.sourceforge.net/d/Log/Log4perl/FAQ.html#e0ed3 You can use the 'easy' notation to define two distinct loggers (read: two distinct categories that don't inherit from one another). But if you want a configuration with two identical loggers (read: identical category), then you need a l4p config file and a 'appender threshold' setting as explained in the FAQ above. Does that help? -- Mike Mike Schilli m...@pe... > > thanks! > -lev > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > log4perl-devel mailing list > log...@li... > https://lists.sourceforge.net/lists/listinfo/log4perl-devel > |
From: Mike S. <m...@pe...> - 2007-03-07 05:49:49
|
On Tue, 6 Mar 2007, Lev Lvovsky wrote: > when not using the easy_init methodology, is it possible to use the > convenience functions provided by it? > > Meaning, do I always necessarily have to get the logger object, and > $logger->warn('...'), is there any way I could be lazy and just WARN > ('...') via the logger that's implied by my package name? Absolutely. As long as you're using use Log::Log4perl qw(:easy); in your current namespace, DEBUG(), WARN(), INFO(), et. al. will be available. It's really independent of using easy_init() vs. init(). If you need something simple, use easy_init(). If it's more complicated, init() is appropriate. The convenience functions will be available regardless, and at no extra cost: http://log4perl.sourceforge.net/d/Log/Log4perl/FAQ.html#f625e -- Mike Mike Schilli m...@pe... > > thanks! > -lev > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > log4perl-devel mailing list > log...@li... > https://lists.sourceforge.net/lists/listinfo/log4perl-devel > |
From: Lev L. <li...@so...> - 2007-03-07 00:26:11
|
when not using the easy_init methodology, is it possible to use the convenience functions provided by it? Meaning, do I always necessarily have to get the logger object, and $logger->warn('...'), is there any way I could be lazy and just WARN ('...') via the logger that's implied by my package name? thanks! -lev |
From: Lev L. <li...@so...> - 2007-03-06 23:34:44
|
Hello, a co-worker has asked why the following snipped doesn't work as imagined: ---------- #!/usr/bin/perl -w use strict; use Log::Log4perl qw(:easy); Log::Log4perl->easy_init( { level => $WARN, file => "STDOUT" }, { level => $INFO, file => ">>info.log" } ); INFO "This is info - should appear on STDOUT"; ---------- his thinking, is that this should not print anything to STDOUT, but rather to info.log, given that STDOUT is reserved for WARN and above. He pointed out the following in the documentation: "As shown above, easy_init() will take any number of different logger definitions as hash references." this is in RE to the Bar::Twix, and :Bar::Mars example - does this only work because of the separate packages that they're defined in? thanks! -lev |
From: Kevin M. G. <cp...@go...> - 2007-02-28 17:18:37
|
Martin Evans wrote: > I think Log::Dispatch::FileRotate is unusable in a multi-process > environment if the processes run as different uids. That's certainly not impossible. In a situation like that, I'd seriously think about talking to a logging daemon like syslog, syslog-ng, or even something like Spread. Syslog is *really* flexible, and you can use Log::Dispatch::Syslog. But one more suggestion that might help, did you try doing "chmod g+s" on the directory that holds the log files? Then all files created in that directory will belong to the group-owner of the directory. This seems to work for me: #here's the script: kgoess@desoto:~ $ cat /tmp/test.pl use Log::Log4perl; my $testfile = '/tmp/testlog/foo.log'; Log::Log4perl->init(\<<EOT); log4perl.category = INFO, FileAppndr1 log4perl.appender.FileAppndr1 = Log::Dispatch::FileRotate log4perl.appender.FileAppndr1.filename = $testfile log4perl.appender.FileAppndr1.mode = append log4perl.appender.FileAppndr1.layout = Log::Log4perl::Layout::SimpleLayout log4perl.appender.FileAppndr1.size = 1 log4perl.appender.FileAppndr1.max = 6 EOT my $log = Log::Log4perl::get_logger(""); for (1..1000){ $log->info("Shu-wa-chi!"x100); } #running it produces these files, note the ownership #and permissions on the directory are g+w and group is me2 kgoess@desoto:~ $ perl /tmp/test.pl kgoess@desoto:~/temp $ ls -lFtra /tmp/testlog/ total 19 drwxrwxrwt 17 root root 3072 Feb 28 09:12 ../ -rw-rw-r-- 1 kgoess me2 1108 Feb 28 09:12 foo.log.6 -rw-rw-r-- 1 kgoess me2 1108 Feb 28 09:12 foo.log.5 -rw-rw-r-- 1 kgoess me2 1108 Feb 28 09:12 foo.log.4 -rw-rw-r-- 1 kgoess me2 1108 Feb 28 09:12 foo.log.3 -rw-rw-r-- 1 kgoess me2 1108 Feb 28 09:12 foo.log.2 -rw-rw-r-- 1 kgoess me2 1108 Feb 28 09:12 foo.log.1 -rw-rw-r-- 1 kgoess me2 1108 Feb 28 09:12 foo.log drwxrwsr-x 2 kgoess me2 1024 Feb 28 09:12 ./ #be a different user kgoess@desoto:~/temp $ sudo su - me2 Password: [me2@desoto ~]$ #and run it as me2 [me2@desoto ~]$ perl /tmp/test.pl [me2@desoto ~]$ ls -lFtra /tmp/testlog/ total 19 drwxrwxrwt 17 root root 3072 Feb 28 09:12 ../ -rw-rw-r-- 1 me2 me2 1108 Feb 28 09:15 foo.log.6 -rw-rw-r-- 1 me2 me2 1108 Feb 28 09:15 foo.log.5 -rw-rw-r-- 1 me2 me2 1108 Feb 28 09:15 foo.log.4 -rw-rw-r-- 1 me2 me2 1108 Feb 28 09:15 foo.log.3 -rw-rw-r-- 1 me2 me2 1108 Feb 28 09:15 foo.log.2 -rw-rw-r-- 1 me2 me2 1108 Feb 28 09:15 foo.log.1 -rw-rw-r-- 1 me2 me2 1108 Feb 28 09:15 foo.log drwxrwsr-x 2 kgoess me2 1024 Feb 28 09:15 ./ The default umask on my machine is 0002, so files are group-writeable by default. -- Happy Trails . . . Kevin M. Goess |
From: Robert J. <yad...@sn...> - 2007-02-28 16:10:54
|
I posted this problem in August last year, but I never got a solution... I'm getting some errors when use the Synchronized appender. My "real" program inits Log4Perl, then forks one or more children to do the work. The parent then just monitors the children (like a good parent does, right? :) ). I have a SIGTERM handler defined in the parent. When I SIGTERM the parent, I get a bunch of errors (shown below) for removal of the semaphore. I'm guessing that one process removes the semaphore before the others are done with it. Perhaps IPC::Shareable is calling DESTROY multiple times (one for each process using that semaphore?) Below is a simple test case which generates the semaphore errors. The errors only occur both of the following are true: 1) using the Synchronized appender, and 2) a SIGTERM handler is defined To reproduce the problem, start *at least 2* instances of the program below in the background, then kill all instances. When I do so, I see these errors: Couldn't remove semaphore set 23789588: Identifier removed at source.pl line 0 Couldn't remove shared memory segment 23789588: Invalid argument at source.pl line 0 Thanks for your help! --------------------------------------------------- #!/usr/bin/perl use strict; use Log::Log4perl qw(get_logger :levels); $SIG{'TERM'} = \&quit; sub quit; #Initialize logger Log::Log4perl->init(\q{ log4perl.rootLogger = DEBUG, SyncScreen log4perl.appender.Screen = Log::Log4perl::Appender::Screen log4perl.appender.Screen.layout = Log::Log4perl::Layout::SimpleLayout log4perl.appender.SyncScreen = Log::Log4perl::Appender::Synchronized log4perl.appender.SyncScreen.appender = Screen }); my $logger = get_logger(); $logger->info("Starting....."); while (1) { sleep (30); } sub quit { exit (); } -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Robert Jacobson .......................... Flight Ops. Team Solar Dynamics Observatory (SDO) ............. .............. |
From: Martin E. <mar...@ea...> - 2007-02-27 16:02:19
|
Thank you to all who replied to my post. Apologies if winding my responses into a single email offends anyone, I am only attempting to save some bandwidth and the moderator some time. A few comments: I think Log::Dispatch::FileRotate is unusable in a multi-process environment if the processes run as different uids. The reason is that you need to specify the permissions so that all uids can write to the file but when Log::Dispatch::FileRotate starts it attempts to do a chmod even if the permissions are already correct. This breaks since the file belongs to uid1 so the second process in as uid2 cannot do that. Kevin Goess' suggestions: > a) after Log4perl::init(), loop through the directory and fix up the > permissions to what they should be > > b) something like this should work: > > #change effective uid while we open the log files > { local $> = getpwnam('nobody'); #or whoever owns them > Log::Log4perl::init() >} (a) works only if you remove the "permission" setting from FileRotate but of course falls down later when the files are automatically rotated because they are created afresh and now as you have not got "permission" set umask comes in to it. As I don't know when the files are rotated I cannot reapply the permission fixup, and I don't want to set umask process wide. (b) similar issue to (a) when the files are rotated but not practical in my circumstances as the process cannot change effective uid. However, I guess this will work fine for John ORourke as he has Apache starting as root, loading his module at startup then writing to it as a "single" different user. Mike Schilli said: > That's a feature that I think needs to be added to > Log::Dispatch::FileRotate, similar to what > Log::Log4perl::Appender::File does. FileRotate's author has been known > to read this mailing list, so maybe it'll come soon :) . A long with, don't attempt to change the permissions if they are already OK. > That being said, there's situations where processes are running as > different users, and all of them are writing to the same logfile. To > avoid permission problems in this scenario (think about what happens > when one user triggers the rotation), I've found it easiest to use an > external rotator instead. Log::Logperl supports this as well: > > http://log4perl.sourceforge.net/d/Log/Log4perl/FAQ.html#2d0d0 Thanks, I read that and have tried it - it works. I was just not that happy about a) sending/capturing a signal since I cannot be 100% sure what other modules and signals are being used. In particular one of the processes uses DBD::Oracle which uses the Oracle instant client and hence Net8 and OCI libs and these catch all sorts of signals. b) I cannot afford to lose a single msg but also cannot afford to set recreate_check_interval = 0. For the moment I've gone back to Log4perl's File Appender and set the "umask" setting. This at least allows me to have a single entry in the log4perl config file for my module and let multiple processes use my module. For now I've given up on automatic file rotation and I guess I'll have to run multiple log4perl configs and have the app stop log4perl logging, rename the file and start log4perl again :-( Thanks again to all who replied. Martin -- Martin J. Evans Easysoft Limited http://www.easysoft.com Martin Evans wrote: > Hi, > > I've been using Log::Log4perl for ages now in a set of CPAN modules we > wrote and internally in a project here. All has been ok, it works well - > thank you. > > This issue is mostly related to Log::Dispatch::FileRotate|File but I am > posting here since I may need advice on an alternative. > > Our log files are getting pretty large and after seeing a post on this > list I decided to try Log::Dispatch::FileRotate. It seemed to work fine > at first. The logging is in a single module, this module is used in > multiple places/processes under different uids and we have a single > config file. One of the places is code running under modperl, the other > is a daemon in perl. > > The first problem was due to umasks and first to start (the daemon or > modperl) created the file and the other couldn't open it. I tried > > log4perl.appender.X1.umask = sub { 0000 } > > but it would seem Log::Dispatch::FileRotate does not know umask. I then > discovered "permissions" so did: > > log4perl.appender.X1.permissions = sub { 0666 } > > and this appears to work until another uid comes along in which case you > get: > > Cannot chmod /tmp/dbix.log to 438: Operation not permitted at > /usr/lib/perl5/site_perl/5.8.8/Log/Dispatch/File.pm line 96 > > I don't get this as Log::Dispatch::File says: > > "If the file does not already exist, the permissions that it should be > created with." > > so I presume this is a bug. > > Am I wasting my time here? Would I be better going back to > Log::Log4perl::Appender::File, using ".umask" and some external file > rotator? Any recommendations? > > Martin |
From: John O. <joh...@o-...> - 2007-02-24 19:23:40
|
Kevin M. Goess wrote: > You're right, there are a bunch of different solutions to the problem, > varying in "neatness" according to taste. Here are a couple > possibilities: > > b) something like this should work: > > #change effective uid while we open the log files > { local $> = getpwnam('nobody'); #or whoever owns them > Log::Log4perl::init() > } Now that's the kind of 'neat' I like! I may have thought of that eventually but so rarely play with active process permissions/users that it would've taken me a long time, many thanks. Of course, for added karma I'll replace 'nobody' with something that fetches the configured apache user from the config tree :) John |
From: Kevin M. G. <cp...@go...> - 2007-02-24 17:29:12
|
You're right, there are a bunch of different solutions to the problem, varying in "neatness" according to taste. Here are a couple possibilities: Assuming you're in a unix-y environment and starting log4perl though a PerlRequire'd script, you could a) after Log4perl::init(), loop through the directory and fix up the permissions to what they should be b) something like this should work: #change effective uid while we open the log files { local $> = getpwnam('nobody'); #or whoever owns them Log::Log4perl::init() } On Feb 23, 2007, at 1:23 PM, John ORourke wrote: > Hi Martin, > > I can't help but I'll be watching for answers because I'm seeing a > possibly related problem when using FileRotate initialised from a > config > file called by Apache. > > I have a mod_perl app which is loaded during Apache startup (while > Apache is root) which calls init_and_watch. > If I have my FileRotate log going at startup, only the server startup > messages get written because the child processes run as 'apache' which > doesn't have permission to write to the file create by Apache while it > was root. > As a workaround I have it commented out in my log4perl config on > startup > then I un-comment it and init_and_watch catches the change and starts > writing. > > Obviously there are a few solutions but I've yet to choose a 'neat' > solution. > > John |