Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Mastering Log::Log4perl

by warriors (Novice)
on Oct 25, 2009 at 21:03 UTC ( #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
Node Status?
node history
Node Type: perlquestion [id://803177]
Approved by moritz
Front-paged by almut
help
Chatterbox?
[ambrus]: (b) a good presentation system that lets the presenter quickly interactively edit the slides live during a presentation, to combine the advantages of blackboard and overhead slide styles in modern tech
[Corion]: Heh - in university, I cheated on (a) by doing blackboard presentations using chalk. But those were 2 hour presentations, not quick/essential/ reduced presentations where you want to show something quick
[ambrus]: (either on just one screen or two screens). this is necessary because
[ambrus]: overhead slide plus blackboard is inconvenient because the lighting conditions are different and they require separate areas you can't quickly repartition, and typing on keyboard is faster and more convenient than writing on a blackboard
[Corion]: (b) would be cool. I've thought about this doing Pod editing, and even simply regenerating/live updating the browser makes things much more interactive
[ambrus]: modern computers have way enough processing power to allow this, at least for geeks who are willing to spend a few weeks to learn a tricky new user interface like vim
[Corion]: ambrus: Well, for mathematical notation, I find blackboard much more convenient than a computer. But when inserting text or moving text around, the computer wins obviously
[ambrus]: But either of these is a big problem in practice, so I'd need to spend like thirty years of my life to solve (a) and five more years to solve (b)
[ambrus]: Corion: yes, CURRENTLY the blackboard is more convenient
[ambrus]: and it's not like I want to ban blackboards anyway

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-09-26 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (293 votes). Check out past polls.

    Notices?