Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: combine logentries with Log::log4perl

by SimonPratt (Friar)
on Sep 03, 2015 at 12:03 UTC ( #1140873=note: print w/replies, xml ) Need Help??


in reply to Re^2: combine logentries with Log::log4perl
in thread combine logentries with Log::log4perl

You appear to be attempting to log to multiple places, hence all the double ups (and probably the cause of stuff not appearing on screen as expected). Try this:

use strict; use warnings; use Log::Log4perl qw(:easy); my $conf = <<EOT; log4perl.rootLogger = DEBUG, Log1 log4perl.appender.Log1 = Log::Log4perl::Appender::File log4perl.appender.Log1.filename = /tmp/test.log log4perl.appender.Log1.mode = append log4perl.appender.Log1.layout = Log::Log4perl::Layout::SimpleLayout log4perl.appender.Log1.Threshold = INFO log4perl.logger = TRACE, Log2 log4perl.appender.Log2 = Log::Log4perl::Appender::ScreenColoredLevels log4perl.appender.Log2.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.Log2.layout.ConversionPattern = %m%n log4perl.category = TRACE, Buffer log4perl.appender.Buffer = Log::Log4perl::Appender::Buffer log4perl.appender.Buffer.appender = Log1 log4perl.appender.Buffer.trigger_level = ERROR EOT Log::Log4perl->init(\$conf); TRACE("message #1 (screen only)"); INFO("message #2"); INFO("message #3"); sleep(10); ERROR("message #4");

EDIT: You've set the buffer to intercept all messages and only allow DEBUG and higher through. Thats why your onscreen TRACE message disappears. Still looking into the doubling up thing.

Oh, and I've updated my source - This gets the screen to display correctly, but everything is still doubled in the file.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1140873]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2019-10-21 02:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?