Subject: | Log::Log4perl::Appender::ScreenColoredLevels |
Date: | Fri, 09 Mar 2012 23:23:51 +0200 |
To: | bug-Log-Log4perl [...] rt.cpan.org |
From: | Meir Guttman <meir [...] guttman.co.il> |
Dear Michael,
First and foremost, thank you for a most useful set of modules!
With regard to the Log::Log4perl::Appender::ScreenColoredLevels, I would like to point two issues:
1) A documentation issue: I would add that on "Windows" systems, the "Win32::Console::ANSI" module is required.
2) A real(?) bug: On windows, even with the above module, it seems that setting screen attributes doesn't work. All colors and other attributes remain the default Test:
use strict;
use warnings;
use Log::Log4perl qw(get_logger :levels); use Win32::Console::ANSI;
my $config_str = q(
log4perl.rootLogger = DEBUG, FileLogger, ScreenLogger
log4perl.appender.ScreenLogger = Log::Log4perl::Appender::ScreenColoredLevels
log4perl.appender.ScreenLogger.stderr = 0
##### The following doesn't seem to work:
log4perl.appender.Screen.color = {fatal => bold cyan}
#####
log4perl.appender.ScreenLogger.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.ScreenLogger.layout.ConversionPattern = %m %n
log4perl.appender.FileLogger = Log::Log4perl::Appender::File
log4perl.appender.FileLogger.filename = mylog.txt
log4perl.appender.FileLogger.mode = append
log4perl.appender.FileLogger.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.FileLogger.layout.ConversionPattern = %d{HH:MM:SS} %F{1}:%L %m %n
log4perl.appender.ScreenLogger.Threshold = WARN );
Log::Log4perl->init(\$config_str);
my $logger = Log::Log4perl->get_logger(); $logger->debug("This is a DEBUG line"); $logger->error("And this is an ERROR log message"); $logger->fatal("And this is FATAL!");
(I am too much of a newbie to supply a patch. Believe me, prior attempts (with other modules) ended miserably ... :-( )
Regards,
Meir Guttman
Ashdod, Israel