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

Log4perl stops logging after update to 1.24

by kreetrapper (Scribe)
on Sep 08, 2009 at 12:24 UTC ( [id://794113]=perlquestion: print w/replies, xml ) Need Help??

kreetrapper has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, fellow monks.

I am using Log4perl 1.20 in my project and it worked fine, but then I updated to version 1.24 a couple of days ago and now nothing is logged anymore.

I looked in the changelog and googled/super-searched a bit, but I found nothing that seems to imply a major change in the way Log4perl works. Maybe one of you is experiencing similar problems and can help me understand what I can do to make my program work again. I could probably switch back to version 1.20 but that doesn't seem like the optimal solution.

Here is a reduced test case which worked fine with Log4perl 1.20 but doesn't output anything with Log4perl 1.24.

use strict; use warnings; use Log::Log4perl; # Define a logger my $log = Log::Log4perl->get_logger("abc.def.ghi"); # Define a logger layout my $layout = Log::Log4perl::Layout::PatternLayout->new("%d > %m %n"); # define appender for console output my $appender_screen = Log::Log4perl::Appender->new("Log::Log4perl::App +ender::Screen",name => 'console'); # Set the appender's layout and add it $appender_screen->layout($layout); $log->add_appender($appender_screen); $log->info("This is an info message"); $log->error("This is an error message");

Replies are listed 'Best First'.
Re: Log4perl stops logging after update to 1.24
by broomduster (Priest) on Sep 08, 2009 at 16:19 UTC
    If I insert the following before your log messages, I get the info and error messages on my terminal.
    use Log::Log4perl::Level; $log->level($ERROR);
    Disclaimer: I only recently started to fiddle with Log::Log4perl, so I don't know if this is new to 1.24 or not, but it at least seems to do what you want.
Re: Log4perl stops logging after update to 1.24
by Anonymous Monk on Sep 08, 2009 at 15:53 UTC

      Ah, thank you so much!

      It's probably a feature that you have to set the log level explicitly. But I still do not understand why this change didn't make it into the release notes.

        Maybe you were using Log::Log4perl->easy_init() before? easy_init sets level to $DEBUG by default.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://794113]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2024-04-25 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found