From: Mike S. <m...@pe...> - 2005-02-05 20:09:13
|
> Nagarajan Murugesan <nag...@at...> wrote: > > I just copy past your code for log4perl screen colour > level, surprisngly it was not working. > > Whats wrong with the code. I just changed the code by > looking at the user guide. Still is fails. Could please > take look at this code. Log::Log4perl::Appender::ScreenColoredLevels uses Term::ANSIColor and works on platforms supporting ANSI color sequences. Linux supports it. You're not explicitely saying which platform you're using, but concluding from > C:\ThinkInPerl\SWAT>perl log.pl it's Windows. I doubt that this will work. -- Mike Mike Schilli m...@pe... > > code in CPAN example: > ===================== > use Log::Log4perl qw(:easy); > > Log::Log4perl->init(\ <<'EOT'); > log4perl.category = DEBUG, Screen > log4perl.appender.Screen = \ > Log::Log4perl::Appender::ScreenColoredLevels > log4perl.appender.Screen.layout = \ > Log::Log4perl::Layout::PatternLayout > log4perl.appender.Screen.layout.ConversionPattern = > \ > %d %F{1} %L> %m %n > EOT > > # Appears black > DEBUG "Debug Message"; > > # Appears green > INFO "Info Message"; > > # Appears blue > WARN "Warn Message"; > > # Appears magenta > ERROR "Error Message"; > > # Appears red > > My Code: > ======== > use Log::Log4perl; > my $conf = q( > log4perl.category = DEBUG, Screen > log4perl.appender.Screen = > Log::Log4perl::Appender::ScreenColoredLevels > log4perl.appender.Screen.layout = > Log::Log4perl::Layout::PatternLayout > log4perl.appender.Screen.layout.ConversionPattern = > %d %F{1} %L> %m %n > ); > Log::Log4perl::init( \$conf ); > my $log = Log::Log4perl::get_logger(); > $log->info("Important Info1!"); > $log->debug("Important Info2!"); > $log->warn("Important Info3!"); > $log->error("Important Info4!"); > $log->fatal("Important Info5!"); > > This gives the output as > > C:\ThinkInPerl\SWAT>perl log.pl > > > It does not print in different color. > Can you please help me out. > > Thanks, > Nagarajan > |