Hello,
It looks like both the root and the Test_Log4perl categories are logging the
same messages from Test_Log4perl if the message levels are higher than the log
level configured for Test_Log4perl. Can we log such messages just once?
Thanks!
Cunzhi Huang
---- sample output -------------
[2010/11/02 22:02:34] WARN log4perl.pl Test_Log4perl::test 21 - warn
[2010/11/02 22:02:34] WARN log4perl.pl Test_Log4perl::test 21 - warn
[2010/11/02 22:02:37] DEBUG log4perl.pl main::main_test 10 - debug
[2010/11/02 22:02:37] INFO log4perl.pl main::main_test 11 - info
[2010/11/02 22:02:37] WARN log4perl.pl Test_Log4perl::test 21 - warn
[2010/11/02 22:02:37] WARN log4perl.pl Test_Log4perl::test 21 - warn
[2010/11/02 22:02:40] DEBUG log4perl.pl main::main_test 10 - debug
[2010/11/02 22:02:40] INFO log4perl.pl main::main_test 11 - info
[2010/11/02 22:02:40] WARN log4perl.pl Test_Log4perl::test 21 - warn
[2010/11/02 22:02:40] WARN log4perl.pl Test_Log4perl::test 21 - warn
[2010/11/02 22:02:43] DEBUG log4perl.pl main::main_test 10 - debug
[2010/11/02 22:02:43] INFO log4perl.pl main::main_test 11 - info
[2010/11/02 22:02:43] WARN log4perl.pl Test_Log4perl::test 21 - warn
[2010/11/02 22:02:43] WARN log4perl.pl Test_Log4perl::test 21 - warn
--- config file ----
# root logger
log4perl.logger=DEBUG, LOGFILE
# override root logger
log4perl.logger.Test_Log4perl = INFO, LOGFILE
log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename=/tmp/log4perl.log
log4perl.appender.LOGFILE.mode=append
log4perl.appender.LOGFILE.layout=PatternLayout
log4perl.appender.LOGFILE.layout.ConversionPattern=[%d] %p %F %M %L - %m%n
--- sample code ---
#!/usr/bin/perl -w
use strict;
use Log::Log4perl;
#
Log::Log4perl::init_and_watch('/root/tmp/perl/log4perl.conf',10);
sub main_test {
my $log = Log::Log4perl::get_logger(); # root logger
$log->debug("debug");
$log->info("info");
}
{
package Test_Log4perl;
sub test {
# need to change config file
my $log = Log::Log4perl::get_logger("Test_Log4perl"); # for this class
$log->debug("debug");
$log->warn("warn");
}
} # end of package
while (1) {
main_test();
Test_Log4perl::test();
sleep 3;
}
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a
Billion" shares his insights and actions to help propel your
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel