|
From: Mike S. <m...@pe...> - 2007-03-07 06:45:04
|
On Tue, 6 Mar 2007, Lev Lvovsky wrote:
> Hello, a co-worker has asked why the following snipped doesn't work
> as imagined:
> use strict;
> use Log::Log4perl qw(:easy);
>
> Log::Log4perl->easy_init(
> { level => $WARN, file => "STDOUT" },
> { level => $INFO, file => ">>info.log" }
> );
>
> INFO "This is info - should appear on STDOUT";
>
> his thinking, is that this should not print anything to STDOUT, but
> rather to info.log, given that STDOUT is reserved for WARN and
> above. He pointed out the following in the documentation:
>
> "As shown above, easy_init() will take any number of different logger
> definitions as hash references."
It's correct that easy_init() will take any number of different logger
definitions as hash references.
But your co-worker fell into the trap explained here:
http://log4perl.sourceforge.net/d/Log/Log4perl/FAQ.html#e0ed3
You can use the 'easy' notation to define two distinct loggers (read: two
distinct categories that don't inherit from one another).
But if you want a configuration with two identical loggers (read:
identical category), then you need a l4p config file and a 'appender
threshold' setting as explained in the FAQ above.
Does that help?
-- Mike
Mike Schilli
m...@pe...
>
> thanks!
> -lev
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> log4perl-devel mailing list
> log...@li...
> https://lists.sourceforge.net/lists/listinfo/log4perl-devel
>
|