Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2020-07-15 05:34 GMT
Find Nodes?
    Voting Booth?

    No recent polls found