The wrapper-level variable probably should be
localized by any class that wraps L4p: there's
no guarantee that no-one will call an un-wrapped
method in L4p and botch the sequcnes.
=head1 Using Log::Log4perl from wrapper classes
If you don't use C<Log::Log4perl> as described above,
but from a wrapper class (like your own Logging class which in turn uses
C<Log::Log4perl>),
the pattern layout will generate wrong data for %F, %C, %L and the like.
Reason for this is that C<Log::Log4perl>'s loggers assume a static
caller depth to the application that's using them. If you're using
one (or more) wrapper classes, C<Log::Log4perl> will indicate where
your logger classes called the loggers, not where your application
called your wrapper, which is probably what you want in this case.
But don't despair, there's a solution: Just increase the value
of C<$Log::Log4perl::caller_depth> (defaults to 0) by one for every
wrapper that's in between your application and C<Log::Log4perl>,
then C<Log::Log4perl> will compensate for the difference.
Using a local variable avoids problems with anyone who
uses Log4perl directly; using ||= allows people to wrap
YOUR wrappers without accidentally resetting the value
too low.
sub debug
{
local $Log::Log4perl::caller_depth ||= 1;
...
}
--
Steven Lembark +1 888 359 3508
Workhorse Computing 85-09 90th St
[EMAIL PROTECTED] Woodhaven, NY 11421
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel