|
From: Mike S. <msc...@ao...> - 2004-01-09 18:14:53
|
Tony Bowden wrote on 1/9/2004, 9:17 AM:
> Thus, in the application, the init() is called per request, based on the
> CGI paramaters received.
init() (or easy_init()) should be called exactly once, when the
application starts up. If you're running a typical CGI-Skript, running
it per request is fine. However, in a persistent environment (like
mod_perl), calling init() (or easy_init()) per request is not
recommended -- what will happen is that the L4p settings for the entire
system will be clobbered and set to the new configuration. If you have
test appenders defined and then you're running easy_init(), L4p will
clobber them and go for the settings defined in easy_init() -- typically
by writing messages to STDOUT.
In your init() call, you specified just one logger:
log4perl.category = INFO, BufferApp
That's the root logger. If you want to reset its level in the new()
call, just do something like
my $logger = Log::Log4perl::get_logger("");
$logger->level($ERROR);
BTW, :easy mode automatically defines loggers (so-called stealth
loggers) named after the current package. So, to get a logger defined by
:easy in the "main" package, do this:
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($DEBUG);
DEBUG("gets logged");
ERROR("gets logged");
my $logger = get_logger("main");
$logger->level($ERROR);
DEBUG("doesn't get logged");
ERROR("gets logged");
--
-- Mike
Mike Schilli
m...@pe...
|