Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Mastering Log::Log4perl

by warriors (Novice)
on Oct 25, 2009 at 21:03 UTC ( [id://803177]=perlquestion: print w/replies, xml ) Need Help??

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

The following is a copy/paste example from the book Mastering Perl.
#!/usr/bin/perl # log4perl-easy3.pl use strict; use warnings; use Log::Log4perl qw(:easy); Log::Log4perl->easy_init( { file => ">> error_log", level => $ERROR, }, { file => "STDERR", level => $DEBUG, } ); ERROR( "I've got something to say!" ); DEBUG( "Hey! What's going on in there?" );
The code should print the ERROR message in the error_log file and both messages on the screen.
What it does is that it print both message on the screen and the error_log file!
What am I missing here?
By the way I am using Strawberry Perl on windows XP, in case this is a platform bug!

Replies are listed 'Best First'.
Re: Mastering Log::Log4perl
by CountZero (Bishop) on Oct 25, 2009 at 22:07 UTC
    I get the same results on ActiveState 5.8.8 on Windows XP Professional, so it is not a platform issue.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: Mastering Log::Log4perl
by Anonymous Monk on Oct 25, 2009 at 21:23 UTC
    Book must suck horribly :)
    use strict; use warnings; use Log::Log4perl qw(:easy); Log::Log4perl->easy_init( { file => ">> error_log", level => $ERROR, }, { file => "STDERR", level => $DEBUG, } ); ERROR( "I've got something to say!" ); DEBUG( "Hey! What's going on in there?" ); print "\$DEBUG = $DEBUG\n\$ERROR = $ERROR\n"; print " THE CURRENT LEVEL IS ", Log::Log4perl->get_logger->level,"\n"; __END__ 2009/10/25 13:23:40 I've got something to say! 2009/10/25 13:23:40 Hey! What's going on in there? $DEBUG = 10000 $ERROR = 40000 THE CURRENT LEVEL IS 10000
      I think log4perl-easy3.pl is an example of what not to do (anti-example?)
Re: Mastering Log::Log4perl
by Anonymous Monk on Oct 26, 2009 at 07:19 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-20 01:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found