Is it possible to get Log4perl to correctly display the line number and package/class of the log event instead of always Method::Delegation at line 99 when used with Moose?
In my case, I have created an attribute isa Log::Log4perl::Logger and delegated the various logging levels to my class (log, warn, error, …). Doing this also shows the Delegation.pm as the file.
You don’t provide nearly enough information to diagnose your issue (e.g. what is Method::Delegation and how is it connected to Log4perl), but my spidey senses tell me you probably have a wrapper method from which you call the Log4perl methods. You should increase the value of
$Log::Log4perl::caller_depthfrom within this wrapper (and decrement it after calling into Log4perl) so the proper location is determined.e.g. in Moose, I use:
Note that the CPAN module MooseX::Log::Log4perl does not increment caller_depth, which it definitely should.