From: <Fp...@ao...> - 2004-07-28 23:59:37
|
Hi, I'm testing out the log4perl on a Windows 2000 machine (Perl 5.6.1) and encountered some unexpected behaviors. I have the following conf file: log1.conf ========== log4perl.rootLogger=DEBUG, LogFile log4perl.appender.LogFile=Log::Log4perl::Appender::File log4perl.appender.LogFile.filename=test.log log4perl.appender.LogFile.mode=append log4perl.appender.LogFile.layout=PatternLayout log4perl.appender.LogFile.layout.ConversionPattern=%p - %d %l: %m%n log4perl.rootLogger.Logger2=DEBUG, NTLog, A2 log4perl.appender.NTLog=Log::Dispatch::Win32EventLog log4perl.appender.NTLog.source=main log4perl.appender.NTLog.layout=PatternLayout log4perl.appender.NTLog.layout.ConversionPattern=%p - %d %l: %m%n log4perl.appender.A2=Log::Log4perl::Appender::Screen log4perl.appender.A2.layout=PatternLayout log4perl.appender.A2.layout.ConversionPattern=%p - %d %l: %m%n logger.pl ========== use strict; use Log::Log4perl; Log::Log4perl->init("log1.conf"); my $logger1 = Log::Log4perl->get_logger("rootLogger.Logger2"); if($logger1->is_debug()) { $logger1->error('This is debug message from logger.pl'); } My problem is that when I run logger.pl, I'm not getting the behavior that I was expecting. The log message is getting sent to the log file "test.log" only, I DO NOT see the same log message on the screen or the Win32 Event Log. I don't think I made any mistakes in my CONF file. I played around with the perl script by changing the string passed to get_Logger() function and the behavior doesn't seem consistent. Sometimes it does what is defined according to the CONF file. However, the moment I update the string parameter passed to get_Logger(), it doesn't give me the results that I was looking for. For example, I first ran the script with get_Logger("rootLogger"). Next, I modify the script so that get_Logger() is passed with "rootLogger.Logger2". I end up with results that corresponds to how "rootLogger" is defined (output to Log file only) instead of what I defined for "rootLogger.Logger2 (STDOUT and Win32 Event Log). Am I doing something wrong here??? Thanks. |