Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Log4Perl configuration problems

by ribasushi (Monk)
on Jun 13, 2008 at 11:04 UTC ( #691875=perlquestion: print w/ replies, xml ) Need Help??
ribasushi has asked for the wisdom of the Perl Monks concerning the following question:

Greetings honorable Monks,

Since the documentation for log4perl sucks massively, I am coming here for advice. Here are my problems:
  1. Depending on the tutorial used one can see log4perl.logger or log4perl.root or log4perl.rootLogger as the name of the top hierarchy logger. This is very confusing - are they aliases to the same thing? Or are they tied in some sort of hierarchy? What is the significance of the text after the dot? (obviously not a category name - there is category.x for that)

  2. How can one do the following (non-working example):
    log4perl.logger = INFO, Screen log4perl.logger = DEBUG, DBGFile ...
    with the obvious intention to log to several places, filtering based only on log level

  3. Are category.x and logger.x completely different subsystems, or do they actually have some inheritance/relationship between them?
Any references to reading material are appreciated - all I could google were quick-start tutorials without much in-depth architecture explanation. I tried to read the source as well, but gave up at the init() stage.

Thanks!

Comment on Log4Perl configuration problems
Select or Download Code
Re: Log4Perl configuration problems
by andreas1234567 (Vicar) on Jun 13, 2008 at 11:46 UTC
    the documentation for log4perl sucks massively
    That's both harsh and completely unfair. In fact, I think the Log::Log4perl documentation is both extensive and well written. Courtesy never hurts, and sometimes helps.
    2. How can one do the following (non-working example):
    You can log both to screen (stderr) and a rotating file like this:
    use Log::Log4perl; use Log::Dispatch::FileRotate; my $conf = undef; my $log = undef; my $help = undef; my $test = undef; my $file = undef; $conf = q( log4perl.category.Script = INFO, ScreenAppender, ScriptFile +RotateAppender log4perl.appender.ScreenAppender = Log::Log4perl::Appender:: +Screen log4perl.appender.ScreenAppender.stderr = 1 log4perl.appender.ScreenAppender.layout = PatternLayout log4perl.appender.ScreenAppender.layout.ConversionPattern=[%p] %d %F +:%L - %m%n log4perl.appender.ScreenAppender.Threshold = DEBUG log4perl.appender.ScriptFileRotateAppender = Log::Dispatch +::FileRotate log4perl.appender.ScriptFileRotateAppender.filename = script.log log4perl.appender.ScriptFileRotateAppender.mode = append log4perl.appender.ScriptFileRotateAppender.size = 100000 log4perl.appender.ScriptFileRotateAppender.max = 5 log4perl.appender.ScriptFileRotateAppender.layout = PatternLayout log4perl.appender.ScriptFileRotateAppender.layout.ConversionPattern= +[%p] %d %F:%L: %m%n ); Log::Log4perl::init( \$conf ); $log = Log::Log4perl::->get_logger(q(Script)); $log->debug("start") if $log->is_debug(); $log->warn("stop") if $log->is_warn();
    --
    No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]
      That's both harsh and completely unfair. In fact, I think the Log::Log4perl documentation is both extensive and well written. Courtesy never hurts, and sometimes helps.
      I am happy you feel this way about the massively incomplete documentation. Just to prove my point - tell me where in the docs is .Threshold being discussed? Certainly not in Log::Log4perl, nor in Log::Log4perl::Config (the only two places where a seasoned CPAN user would look). The only place I found this modifier (after your hint) was in the FAQ, and even then - it was in sections completely unrelated to my problem.

      Thank you, nevertheless, for pointing me in the right direction. I stand by my words however.
        The References section has a link to an article that complements the documentation well. It says (on page 3):
        Each appender can define a so-called appender threshold, a minimum level required for an oncoming message to be honored by the appender:
        $appender->threshold($ERROR);
        If the level doesn't meet the appender's threshold, then it is simply ignored by this appender.
        Was that what you were looking for?
        --
        No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]
Re: Log4Perl configuration problems
by Anonymous Monk on Jun 13, 2008 at 13:36 UTC

    As a sidenote here, if you think a given distribution has lousy docs, and you have any choice in the matter, you should probably email the maintainer (with constructive criticism) and then not use said module if there's no improvement.

    Silently using modules with bad docs sends the message that docs don't matter because you'll use the software anyway.

      Generally you are correct, however this module is ahead of the crowd by leaps and bounds. The design is too good to pass on it over documentation issues. It's like saying "I won't use IO::Socket because the docs suck".

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2014-07-22 12:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (113 votes), past polls