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: David C. <dpc...@ho...> - 2011-09-29 17:39:31
|
On 09/28/2011 11:04 PM, Mike Schilli wrote: > If you want to bump up the caller level, you should be using > wrapper_register() or $Log::Log4perl::caller_depth as explained here: > http://search.cpan.org/dist/Log-Log4perl/lib/Log/Log4perl.pm#Using_Log::Log4perl_with_wrapper_functions_and_classes Yes. On 09/28/2011 11:04 PM, Mike Schilli wrote: > On Wed, 28 Sep 2011, David Christensen wrote: >> Ok. I've upgraded my wrapper functions to use caller() when calling >> get_logger(). > That doesn't sound right. My wrappers now call, in effect: get_logger('caller.package.subroutine.line') This should give me more opportunities to use categories. David |
From: Robert R. <ro...@gm...> - 2011-09-29 12:34:25
|
It seems that when I use the no_extra_logdie_message option, the logdie and logcroak methods do not work with Test::Exception's throws_ok or dies_ok functions. Those functions just exit with errors. This happens even when the test script is outputting to the screen. Is there a way to use no_extra_logdie_message option with Test::Exception? |
From: Mike S. <m...@pe...> - 2011-09-29 06:05:21
|
On Wed, 28 Sep 2011, David Christensen wrote: > Ok. I've upgraded my wrapper functions to use caller() when calling > get_logger(). That doesn't sound right. If you want to bump up the caller level, you should be using wrapper_register() or $Log::Log4perl::caller_depth as explained here: http://search.cpan.org/dist/Log-Log4perl/lib/Log/Log4perl.pm#Using_Log::Log4perl_with_wrapper_functions_and_classes -- -- Mike Mike Schilli m...@pe... > On 09/26/2011 10:14 AM, Mike Schilli wrote: >> Actually, :easy mode macros and get_logger() are identical in function, >> the difference is just typing convenience. >> >> I personally use :easy macros like DEBUG and INFO in conjunction with >> log4perl configuration files, unless for really simple scripts for which >> easy_init() is more appropriate. > |
From: David C. <dpc...@ho...> - 2011-09-29 05:49:45
|
On 09/26/2011 10:14 AM, Mike Schilli wrote: > Actually, :easy mode macros and get_logger() are identical in function, > the difference is just typing convenience. > > I personally use :easy macros like DEBUG and INFO in conjunction with > log4perl configuration files, unless for really simple scripts for which > easy_init() is more appropriate. Ok. I've upgraded my wrapper functions to use caller() when calling get_logger(). Thanks! David |
From: Mike S. <m...@pe...> - 2011-09-26 17:15:12
|
On Sun, 25 Sep 2011, David Christensen wrote: > I'd like to upgrade > everything to whatever is consider best (or better) > practices. Actually, :easy mode macros and get_logger() are identical in function, the difference is just typing convenience. I personally use :easy macros like DEBUG and INFO in conjunction with log4perl configuration files, unless for really simple scripts for which easy_init() is more appropriate. -- -- Mike Mike Schilli m...@pe... > I started with Log4perl a few months ago and wrote some modules that > use Log4perl in easy mode with no get_logger() categories. I'm now > working on more modules and an application that uses Log4perl > configuration files and get_logger() categories. |
From: David C. <dpc...@ho...> - 2011-09-26 05:24:04
|
log4perl: I started with Log4perl a few months ago and wrote some modules that use Log4perl in easy mode with no get_logger() categories. I'm now working on more modules and an application that uses Log4perl configuration files and get_logger() categories. I'd like to upgrade everything to whatever is consider best (or better) practices. Any suggestions? TIA, David |
From: David C. <dpc...@ho...> - 2011-09-20 19:41:23
|
On 09/19/2011 11:37 PM, Kevin Goess wrote: > See 'perldoc Log::Log4perl::Filter' On 09/20/2011 12:20 AM, Mike Schilli wrote: > The Log::Log4perl::Filter manpage explains their use in detail. That solved it. Thanks! :-) 2011-09-20 12:38:06 dpchrist@p43400e ~ $ grep Trace perl-src/50-Dpchrist-CMS/demo/conf/log4perl.conf log4perl.logger = TRACE, InfoApp, TraceApp log4perl.filter.TraceFilter = sub {$ENV{REMOTE_ADDR} eq $Mysite::CONF{-trace_ip}} log4perl.appender.TraceApp = Log::Log4perl::Appender::File log4perl.appender.TraceApp.filename = sub { File::Spec::Functions::catfile($Mysite::CONF{-log_dir}, 'trace.log') } log4perl.appender.TraceApp.Filter = TraceFilter log4perl.appender.TraceApp.mode = append log4perl.appender.TraceApp.layout = PatternLayout log4perl.appender.TraceApp.layout.ConversionPattern = %d{yyyyMMdd-HHmmss.SSS} %p %M (%F{1} %L) %m{chomp}%n log4perl.appender.TraceApp.Threshold = TRACE David |
From: Mike S. <m...@pe...> - 2011-09-20 07:41:44
|
On Mon, 19 Sep 2011, David Christensen wrote: > I would prefer to enable/ disable TraceApp based on $ENV{REMOTE_ADDR} > rather than doing all the work and throwing non-192.168.0.34 hits down > /dev/null, but I couldn't figure out how to implement this idea. Hi David, you can use Log4perl's custom filters. If you add log4perl.filter.MyFilter = sub { $ENV{REMOTE_ADDR} eq '192.168.0.34' } log4perl.appender.TraceApp.Filter = MyFilter to your configuration, it'll suppress all messages to the appender that aren't from your test client. The Log::Log4perl::Filter manpage explains their use in detail. Hope that helps! -- -- Mike Mike Schilli m...@pe... > log4perl-devel: > > I'm working on a web application and would like to log TRACE priority > messages related to hits from my development machine (IP address > 192.168.0.34). This is the relevant portion of my configuration file: > > 2011-09-19 12:31:51 dpchrist@p43400e ~ > $ grep TraceApp perl-src/50-Dpchrist-CMS/demo/conf/log4perl.conf > log4perl.logger = TRACE, InfoApp, TraceApp > log4perl.appender.TraceApp = Log::Log4perl::Appender::File > log4perl.appender.TraceApp.filename = sub { $ENV{REMOTE_ADDR} eq > '192.168.0.34' ? $Mysite::CONF{-log_dir} . '/trace.log' : '/dev/null' } > log4perl.appender.TraceApp.mode = append > log4perl.appender.TraceApp.layout = PatternLayout > log4perl.appender.TraceApp.layout.ConversionPattern = > %d{yyyyMMdd-HHmmss.SSS} %p %M (%F{1} %L) %m{chomp}%n > log4perl.appender.TraceApp.Threshold = TRACE > > |
From: Kevin G. <cp...@go...> - 2011-09-20 07:03:28
|
David, one way you can do this is by attaching a filter to your TraceApp appender, like this log4perl.filter.NotIfDevIP = sub { $ENV{REMOTE_ADDR} eq '192.168.0.34' ? 0 : 1 } log4perl.appender.TraceApp.Filter = NotIfDevIP See 'perldoc Log::Log4perl::Filter' On Mon, Sep 19, 2011 at 9:39 PM, David Christensen < dpc...@ho...> wrote: > log4perl-devel: > > I'm working on a web application and would like to log TRACE priority > messages related to hits from my development machine (IP address > 192.168.0.34). This is the relevant portion of my configuration file: > > 2011-09-19 12:31:51 dpchrist@p43400e ~ > $ grep TraceApp perl-src/50-Dpchrist-CMS/demo/conf/log4perl.conf > log4perl.logger = TRACE, InfoApp, TraceApp > log4perl.appender.TraceApp = Log::Log4perl::Appender::File > log4perl.appender.TraceApp.filename = sub { $ENV{REMOTE_ADDR} eq > '192.168.0.34' ? $Mysite::CONF{-log_dir} . '/trace.log' : '/dev/null' } > log4perl.appender.TraceApp.mode = append > log4perl.appender.TraceApp.layout = PatternLayout > log4perl.appender.TraceApp.layout.ConversionPattern = > %d{yyyyMMdd-HHmmss.SSS} %p %M (%F{1} %L) %m{chomp}%n > log4perl.appender.TraceApp.Threshold = TRACE > > > I would prefer to enable/ disable TraceApp based on $ENV{REMOTE_ADDR} > rather than doing all the work and throwing non-192.168.0.34 hits down > /dev/null, but I couldn't figure out how to implement this idea. > > > Is there a better way? > |
From: David C. <dpc...@ho...> - 2011-09-19 19:56:02
|
log4perl-devel: I'm working on a web application and would like to log TRACE priority messages related to hits from my development machine (IP address 192.168.0.34). This is the relevant portion of my configuration file: 2011-09-19 12:31:51 dpchrist@p43400e ~ $ grep TraceApp perl-src/50-Dpchrist-CMS/demo/conf/log4perl.conf log4perl.logger = TRACE, InfoApp, TraceApp log4perl.appender.TraceApp = Log::Log4perl::Appender::File log4perl.appender.TraceApp.filename = sub { $ENV{REMOTE_ADDR} eq '192.168.0.34' ? $Mysite::CONF{-log_dir} . '/trace.log' : '/dev/null' } log4perl.appender.TraceApp.mode = append log4perl.appender.TraceApp.layout = PatternLayout log4perl.appender.TraceApp.layout.ConversionPattern = %d{yyyyMMdd-HHmmss.SSS} %p %M (%F{1} %L) %m{chomp}%n log4perl.appender.TraceApp.Threshold = TRACE I would prefer to enable/ disable TraceApp based on $ENV{REMOTE_ADDR} rather than doing all the work and throwing non-192.168.0.34 hits down /dev/null, but I couldn't figure out how to implement this idea. Is there a better way? TIA, David |
From: Mike S. <m...@pe...> - 2011-08-18 03:35:44
|
On Wed, 17 Aug 2011, Richard Thomas wrote: > Do you know if anyone has had any success with using Log4perl in > Strawberry Perl? Yes, it works with Strawberry Perl. > The reason I ask is that I'm using Strawberry Perl for the first time > and a script that normally works in Activestate Perl is not working in > Strawberry Perl. You're using a 3rd party appender, Log::Dispatch::FileRotate appender, which isn't part of Log4perl. While I know that Log4perl works with Strawberry Perl, I don't know about 3rd party appenders. Can you give it a try using Log::Log4perl::Appender::File instead? Also, make sure you're using the latest Log4perl from CPAN. -- -- Mike Mike Schilli m...@pe... > > The error I get is "undefined value provided for log level at > C:/strawberry/perl/site/lib/Log/Log4perl/Appender.pm line 80". > > I've extracted some lines on my script below, so you can see how I setup and use > Log4perl. > > Please could you let me know if you can think of anything I can try to get this > working. > > Thanks, > > Richard. > > > > > use strict; > use warnings; > > use Date::Manip; > use Log::Log4perl; > > use Storable; > > use String::Parity; > use String::Parity qw(:DEFAULT /show/); > > use IO::Socket; > use Time::HiRes qw(time); > <snip> > my $log_conf1 = q/ > log4perl.category = INFO, Logfile, Logscreen > log4perl.appender.Logfile = Log::Dispatch::FileRotate > log4perl.appender.Logfile.filename = /; > > my $log_conf2 = q/ > log4perl.appender.Logfile.mode = append > log4perl.appender.Logfile.DatePattern = yyyy-mm-dd > log4perl.appender.Logfile.TZ = GMT0BST > log4perl.appender.Logfile.layout = > Log::Log4perl::Layout::PatternLayout > log4perl.appender.Logfile.layout.ConversionPattern = %d %m %n > > log4perl.appender.Logscreen = > Log::Log4perl::Appender::Screen > log4perl.appender.Logscreen.str = 0 > log4perl.appender.Logscreen.layout = > Log::Log4perl::Layout::PatternLayout > log4perl.appender.Logscreen.layout.ConversionPattern = %m %n > > /; > > my$log_conf=sprintf("%s%s.%s.log\n%s",$log_conf1,$ScriptNoExt,$dateformat,$log_conf > 2); > > Log::Log4perl::init( \$log_conf ); > > my $logger = Log::Log4perl::get_logger(); > <snip> > > |
From: Richard T. <ric...@gm...> - 2011-08-17 12:24:27
|
Hi, Do you know if anyone has had any success with using Log4perl in Strawberry Perl? The reason I ask is that I'm using Strawberry Perl for the first time and a script that normally works in Activestate Perl is not working in Strawberry Perl. The error I get is "undefined value provided for log level at C:/strawberry/perl/site/lib/Log/Log4perl/Appender.pm line 80". I've extracted some lines on my script below, so you can see how I setup and use Log4perl. Please could you let me know if you can think of anything I can try to get this working. Thanks, Richard. use strict; use warnings; use Date::Manip; use Log::Log4perl; use Storable; use String::Parity; use String::Parity qw(:DEFAULT /show/); use IO::Socket; use Time::HiRes qw(time); <snip> my $log_conf1 = q/ log4perl.category = INFO, Logfile, Logscreen log4perl.appender.Logfile = Log::Dispatch::FileRotate log4perl.appender.Logfile.filename = /; my $log_conf2 = q/ log4perl.appender.Logfile.mode = append log4perl.appender.Logfile.DatePattern = yyyy-mm-dd log4perl.appender.Logfile.TZ = GMT0BST log4perl.appender.Logfile.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.Logfile.layout.ConversionPattern = %d %m %n log4perl.appender.Logscreen = Log::Log4perl::Appender::Screen log4perl.appender.Logscreen.str = 0 log4perl.appender.Logscreen.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.Logscreen.layout.ConversionPattern = %m %n /; my $log_conf=sprintf("%s%s.%s.log\n%s",$log_conf1,$ScriptNoExt,$dateformat,$log_conf2); Log::Log4perl::init( \$log_conf ); my $logger = Log::Log4perl::get_logger(); <snip> |
From: Mike S. <m...@pe...> - 2011-08-09 06:12:09
|
On Tue, 9 Aug 2011, Holger Jahn wrote: > Now, we would like to add some generic info to all of the logged > messages (OS name & version, for instance). Is there a way of telling > Log4perl to do this, i.e. without having to add this info manually to > all of the existing places where we currently log stuff? Hi Holger, absolutely, that's exactly what the so-called Mapped Diagnostic Context in Log4perl is for. As explained here: http://search.cpan.org/~mschilli/Log-Log4perl-1.33/lib/Log/Log4perl.pm#Mapped_Diagnostic_Context_%28MDC%29 your application can set certain values via MDC and your Log4perl layout can be configured to display the set value via the %X{name} placeholder in all your messages, without the need to touch the code of the application. Hope that helps. -- -- Mike Mike Schilli m...@pe... |
From: Holger J. <li...@lo...> - 2011-08-09 04:54:59
|
Hi there, We are having a quite big application that uses Log4perl extensively all over the place. We added an email appender to send error messages to the developers as they occur, which works out nicely. Now, we would like to add some generic info to all of the logged messages (OS name & version, for instance). Is there a way of telling Log4perl to do this, i.e. without having to add this info manually to all of the existing places where we currently log stuff? Many thanks, Holger |
From: Mike S. <m...@pe...> - 2011-08-09 03:15:29
|
On Mon, 8 Aug 2011, Bret Jordan wrote: > Or how do we make init_and_wait work for a ref to a hash that contains > the config?. What I would like is something like the following: > ... > ### Now this is where you would change the running config per say, basically adding a > second output > $ref->{log4perl.rootLogger} = "SCREEN, SCREEN1"; > $logger->info("this is more info log message"); > But this does not obviously work. All that's missing is a call to Log::Log4perl->init() with the changed hash afterwards. You could even encapsulate that call and offer a function that does both, change the data structure and call init(). If you want to get really fancy, you could offer a tied hash, intercept the STORE function and call init() whenever something changes. Would that work for you? -- -- Mike Mike Schilli m...@pe... |
From: Bret J. <bre...@ut...> - 2011-08-08 17:53:52
|
Dear Authors, First I would like to say how great your tool Log::Log4perl module is. Well done. I do have a question on how to make changes on the fly without using the init_and_wait feature that is only for the configuration file. Or how do we make init_and_wait work for a ref to a hash that contains the config?. What I would like is something like the following: use Log::Log4perl; # Initialize Logger my %log_conf = ( 'log4perl.rootLogger' => "SCREEN", 'log4perl.appender.SCREEN' => "Log::Log4perl::Appender::Screen", 'log4perl.appender.SCREEN.stderr' => "0", 'log4perl.appender.SCREEN.layout' => "Log::Log4perl::Layout::PatternLayout", 'log4perl.appender.SCREEN.layout.ConversionPattern' => "%d %p %m %n", 'log4perl.appender.SCREEN1' => "Log::Log4perl::Appender::Screen", 'log4perl.appender.SCREEN1.stderr' => "0", 'log4perl.appender.SCREEN1.layout' => "Log::Log4perl::Layout::PatternLayout", 'log4perl.appender.SCREEN1.layout.ConversionPattern' => "FOOBAR %m %n", ); my $ref = \%log_conf; Log::Log4perl::init($ref); my $logger = Log::Log4perl->get_logger(); $logger->info("this is an info log message"); ################### ### Now this is where you would change the running config per say, basically adding a second output #################### $ref->{log4perl.rootLogger} = "SCREEN, SCREEN1"; $logger->info("this is more info log message"); But this does not obviously work. How would you suggest this work? Could you do something like: $logger->{log4perl.rootLogger} = "SCREEN, SCREEN1"; Thanks in advance. Bret |
From: Mike S. <m...@pe...> - 2011-07-29 15:34:14
|
On Fri, 29 Jul 2011, Robert Rothenberg wrote: > When I set the threshold of the second appender, it seems to override > the threshold of the root appender. Not sure what you're referring to here, but if you post your configuration and explain what you're expecting and what you're getting instead, I'll take a look. -- -- Mike Mike Schilli m...@pe... |
From: Robert R. <ro...@gm...> - 2011-07-29 11:53:25
|
I think I've found the problem. When I set the threshold of the second appender, it seems to override the threshold of the root appender. On 26/07/11 16:47 Mike Schilli wrote: > On Tue, 26 Jul 2011, Robert Rothenberg wrote: > >> I've tried changing the threshold for the shared log to INFO >> log4perl.appender.SharedLog.Treshold = INFO > > If you fix the typo ("Treshold" => "Threshold"), that's exactly the > recommended way to accomplish what you want. > |
From: Mike S. <m...@pe...> - 2011-07-26 16:11:04
|
On Tue, 26 Jul 2011, Robert Rothenberg wrote: > I've tried changing the threshold for the shared log to INFO > log4perl.appender.SharedLog.Treshold = INFO If you fix the typo ("Treshold" => "Threshold"), that's exactly the recommended way to accomplish what you want. -- -- Mike Mike Schilli m...@pe... > > but the DEBUG messages still get added to it. > > I've also tried using a subcategory: > > log4perl.logger.mytool = INFO, SharedLog > log4perl.logger.mytool.debug = DEBUG, DebugLog > > and then using > > $logger = get_logger("mytool.debug"); > > but still the DEBUG messages show up in the SharedLog. > > Thanks in advance, > Rob > > ------------------------------------------------------------------------------ > Magic Quadrant for Content-Aware Data Loss Prevention > Research study explores the data loss prevention market. Includes in-depth > analysis on the changes within the DLP market, and the criteria used to > evaluate the strengths and weaknesses of these DLP solutions. > http://www.accelacomm.com/jaw/sfnl/114/51385063/ > _______________________________________________ > log4perl-devel mailing list > log...@li... > https://lists.sourceforge.net/lists/listinfo/log4perl-devel > |
From: Robert R. <ro...@gm...> - 2011-07-26 13:58:46
|
I have a collection of related tools that write to a shared log, generally at the INFO or WARNING level. One of the tools has a separate log that it writes to at a lower level (DEBUG or TRACE). But I still want higher priority messages to show up in the shared log. The problem that I am having is that the DEBUG log messages for the tool also go into the shared log. I've tried changing the threshold for the shared log to INFO log4perl.appender.SharedLog.Treshold = INFO but the DEBUG messages still get added to it. I've also tried using a subcategory: log4perl.logger.mytool = INFO, SharedLog log4perl.logger.mytool.debug = DEBUG, DebugLog and then using $logger = get_logger("mytool.debug"); but still the DEBUG messages show up in the SharedLog. Thanks in advance, Rob |
From: Mike S. <m...@pe...> - 2011-07-24 03:19:00
|
Hi Steve, you're using two different loggers, "SCRIPT" and "MODULE". Your script sets the "SCRIPT" logger defined via log4perl.category.SCRIPT = ERROR, script in the configuration to level "INFO" in the main script: $logger->level("INFO"); This causes the main script to log at this level. But since your module logger stays on "ERROR", as defined in the configuration: log4perl.category.MODULE = ERROR, moduleDebug, moduleRest you're not seeing its log messages in your output. To set the "MODULE" logger to level "INFO" as well, you'd have to do something like use Log::Log4perl qw(get_logger); my $module_logger = get_logger("MODULE"); $module_logger->level( "INFO" ); in your main script (or something similar as you did with the "SCRIPT" logger in Logging.pm). After doing this, you'll see [2011-07-23 19:50:03] script.pl INFO: Calling logTest() [2011-07-23 19:50:03] Package INFO: info message [2011-07-23 19:50:03] Package WARN: warn message [2011-07-23 19:50:03] Package ERROR: error message as (hopefully) expected. Hope that helps. -- Mike Mike Schilli m...@pe... On Fri, 22 Jul 2011, Steve Chadsey wrote: > I have a script that "use"s various other modules. The script will > take a command-line argument that dictates the log level, i.e., "WARN", > "ERROR", etc. The script initializes a Log4perl instance using this level. > The script calls functions from the external modules, for which I would > like to have Log4perl log using the same log level that the calling script > has initialized. > > Here is a simple example of what I have: > > ---[start Logging.pm]----- > #!/usr/bin/perl -w > package Logging; > use strict; > use Log::Log4perl qw(get_logger :levels); > use base 'Exporter'; > > our @EXPORT_OK = qw($dbg_method_msg $logger statusMessage logMessage); > my $log_conf = q{ > log4perl.category.MODULE = ERROR, moduleDebug, moduleRest > # Filter to match level DEBUG > log4perl.filter.MatchDebug = Log::Log4perl::Filter::LevelMatch > log4perl.filter.MatchDebug.LevelToMatch = DEBUG > log4perl.filter.MatchDebug.AcceptOnMatch = true > > # Filter to match everything but DEBUG > log4perl.filter.MatchRest = Log::Log4perl::Filter::LevelMatch > log4perl.filter.MatchRest.LevelToMatch = DEBUG > log4perl.filter.MatchRest.AcceptOnMatch = false > > # layout for DEBUG messages > log4perl.appender.moduleDebug = Log::Log4perl::Appender::Screen > log4perl.appender.moduleDebug.layout = > Log::Log4perl::Layout::PatternLayout > log4perl.appender.moduleDebug.layout.ConversionPattern = > [%d{yyyy-MM-dd HH:mm:ss}] %M:%L %p: %m%n > log4perl.appender.moduleDebug.Filter = MatchDebug > log4perl.appender.moduleDebug.stderr = 0 > > > # Normal layout for the rest > log4perl.appender.moduleRest = Log::Log4perl::Appender::Screen > log4perl.appender.moduleRest.layout = Log::Log4perl::Layout::PatternLayout > log4perl.appender.moduleRest.layout.ConversionPattern = > [%d{yyyy-MM-dd HH:mm:ss}] %C %p: %m%n > log4perl.appender.moduleRest.Filter = MatchRest > log4perl.appender.moduleRest.stderr = 0 > > log4perl.category.SCRIPT = ERROR, script > log4perl.appender.script = Log::Log4perl::Appender::Screen > log4perl.appender.script.stderr = 0 > log4perl.appender.script.layout = Log::Log4perl::Layout::PatternLayout > log4perl.appender.script.layout.ConversionPattern = [%d{yyyy-MM-dd > HH:mm:ss}] %F{1} %p: %m%n > }; > > Log::Log4perl->init( \$log_conf ); > > sub scriptInit > { > our $logger = get_logger("SCRIPT"); > } > 1; > ---[end Logging.pm]----- > > ---[start Package.pm]----- > #!/usr/bin/perl -w > package Package; > use strict; > use Carp qw( carp croak ); > use Logging; > use Log::Log4perl qw(get_logger ); > my $logger = Log::Log4perl->get_logger("MODULE"); > > use vars qw( @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS ); > use Exporter; > @ISA = qw(Exporter); > @EXPORT = qw(); > @EXPORT_OK = > qw( > logTest > ); > > sub logTest > { > $logger->info("info message"); > $logger->warn("warn message"); > $logger->error("error message"); > } > > 1; > ---[end Package.pm]----- > > ---[start script.pl]----- > #!/usr/bin/perl -w > use strict; > #use FindBin; > #use lib "$FindBin::RealBin/../../../lib"; > use Logging qw( $logger ); > use Package qw(logTest ); > > Logging->scriptInit(); > > $logger->level("INFO"); > $logger->info("Calling logTest()"); > logTest(); > ---[end]----- > > As it stands, the output of this script is: > > [2011-07-22 10:58:41] script.pl INFO: Calling logTest() > [2011-07-22 10:58:41] Package ERROR: error message > > What I want is: > > [2011-07-22 10:58:41] script.pl INFO: Calling logTest() > [2011-07-22 10:58:41] Package INFO: info message > [2011-07-22 10:58:41] Package WARN: warn message > [2011-07-22 10:58:41] Package ERROR: error message > > How can I do that? > > Thanks, > |
From: Steve C. <sch...@gm...> - 2011-07-22 17:01:02
|
I have a script that "use"s various other modules. The script will take a command-line argument that dictates the log level, i.e., "WARN", "ERROR", etc. The script initializes a Log4perl instance using this level. The script calls functions from the external modules, for which I would like to have Log4perl log using the same log level that the calling script has initialized. Here is a simple example of what I have: ---[start Logging.pm]----- #!/usr/bin/perl -w package Logging; use strict; use Log::Log4perl qw(get_logger :levels); use base 'Exporter'; our @EXPORT_OK = qw($dbg_method_msg $logger statusMessage logMessage); my $log_conf = q{ log4perl.category.MODULE = ERROR, moduleDebug, moduleRest # Filter to match level DEBUG log4perl.filter.MatchDebug = Log::Log4perl::Filter::LevelMatch log4perl.filter.MatchDebug.LevelToMatch = DEBUG log4perl.filter.MatchDebug.AcceptOnMatch = true # Filter to match everything but DEBUG log4perl.filter.MatchRest = Log::Log4perl::Filter::LevelMatch log4perl.filter.MatchRest.LevelToMatch = DEBUG log4perl.filter.MatchRest.AcceptOnMatch = false # layout for DEBUG messages log4perl.appender.moduleDebug = Log::Log4perl::Appender::Screen log4perl.appender.moduleDebug.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.moduleDebug.layout.ConversionPattern = [%d{yyyy-MM-dd HH:mm:ss}] %M:%L %p: %m%n log4perl.appender.moduleDebug.Filter = MatchDebug log4perl.appender.moduleDebug.stderr = 0 # Normal layout for the rest log4perl.appender.moduleRest = Log::Log4perl::Appender::Screen log4perl.appender.moduleRest.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.moduleRest.layout.ConversionPattern = [%d{yyyy-MM-dd HH:mm:ss}] %C %p: %m%n log4perl.appender.moduleRest.Filter = MatchRest log4perl.appender.moduleRest.stderr = 0 log4perl.category.SCRIPT = ERROR, script log4perl.appender.script = Log::Log4perl::Appender::Screen log4perl.appender.script.stderr = 0 log4perl.appender.script.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.script.layout.ConversionPattern = [%d{yyyy-MM-dd HH:mm:ss}] %F{1} %p: %m%n }; Log::Log4perl->init( \$log_conf ); sub scriptInit { our $logger = get_logger("SCRIPT"); } 1; ---[end Logging.pm]----- ---[start Package.pm]----- #!/usr/bin/perl -w package Package; use strict; use Carp qw( carp croak ); use Logging; use Log::Log4perl qw(get_logger ); my $logger = Log::Log4perl->get_logger("MODULE"); use vars qw( @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS ); use Exporter; @ISA = qw(Exporter); @EXPORT = qw(); @EXPORT_OK = qw( logTest ); sub logTest { $logger->info("info message"); $logger->warn("warn message"); $logger->error("error message"); } 1; ---[end Package.pm]----- ---[start script.pl]----- #!/usr/bin/perl -w use strict; #use FindBin; #use lib "$FindBin::RealBin/../../../lib"; use Logging qw( $logger ); use Package qw(logTest ); Logging->scriptInit(); $logger->level("INFO"); $logger->info("Calling logTest()"); logTest(); ---[end]----- As it stands, the output of this script is: [2011-07-22 10:58:41] script.pl INFO: Calling logTest() [2011-07-22 10:58:41] Package ERROR: error message What I want is: [2011-07-22 10:58:41] script.pl INFO: Calling logTest() [2011-07-22 10:58:41] Package INFO: info message [2011-07-22 10:58:41] Package WARN: warn message [2011-07-22 10:58:41] Package ERROR: error message How can I do that? Thanks, -- Steve Chadsey <sch...@gm...> |
From: Mike S. <m...@pe...> - 2011-06-01 07:19:31
|
Dear Log4perl enthusiasts, Log::Log4perl 1.33 has just been released to CPAN. The maintenance release contains a number of fixes for bugs reported on rt.cpan.org: 1.33 (2011/05/31) * (ms) [RT 67132] Applied patch by Darin McBride to allow for empty syswrite messages in the file appender. * (ms) [RT 68105] Fixed init-hash handling of subroutine references, reported by Frew Schmidt. * (ms) Mike Schwern noticed confusing DESTROY calls to clean up loggers and appenders (http://stackoverflow.com/questions/5914088 and https://github.com/mschilli/log4perl/issues/7), so I put on my hazmat suit and cleaned it up. Now perl's garbage collector takes care of disposing of logger and appender carcasses. * (ms) Added Log::Log4perl->remove_logger($logger) to remove a logger from the system. Enjoy! -- Mike Mike Schilli m...@pe... |
From: Mike S. <m...@pe...> - 2011-04-24 19:25:19
|
On Thu, 14 Apr 2011, Nan Cui wrote: > When my code tried to create new > threads, the logger in the sub-thread body threw out exception like this: > thread failed to start: DBD::Oracle::db prepare failed: handle 2 is owned by > thread 83e0008 not current thread 8973c18 (handles can't be shared between > threads and your driver may need a CLONE method added) at Hi Nan, That might be a limitation in the Oracle driver. I'm not using Oracle personally, but I've gotten feedback on the DBI driver being piece of work, mainly due to the proprietary nature of the Oracle client interface. Anyway, if the driver doesn't allow sharing DB handles between Perl threads, you should be able to work around the problem by explicitly obtaining a new DB handle every time you create a new thread. For this, you need to call the _init() method of Log4perl's DBI appender, which you can do after retrieving the appender by name. Something like Log::Log4perl->appender_by_name( "DBAppndr" )->_init(); in your consume() function should do the trick. -- Mike Mike Schilli m...@pe... |
From: Mike S. <m...@pe...> - 2011-04-15 02:26:44
|
On Thu, 14 Apr 2011, Nan Cui wrote: > I tried to share the logger, but it came out with another error saying > "(in cleanup) Can't call method "FIRSTKEY" on an undefined value at > ..... /Log/Log4perl/Logger.pm line 90 during global destruction.". Can you post a snippet of code to reproduce this problem? -- Mike Mike Schilli m...@pe... |