[Catalyst] Catalyst::Log::Log4perl log duplicates

Marius Kjeldahl mariusauto-catalyst at kjeldahl.net
Mon Jan 7 13:53:53 GMT 2008


I'm trying to use Catalyst::Log::Log4perl with Catalyst. My "main"
package is called MintApp.pm, where I do the following calls:

use Catalyst::Log::Log4perl;
...
__PACKAGE__->log (Catalyst::Log::Log4perl->new ('mintapp-log.conf'));

The conf file looks as follows:

log4perl.logger.MintApp=ERROR, SCREEN
log4perl.logger.MintApp.Controller=ERROR, SCREEN
log4perl.logger.MintApp.Controller.Pub=DEBUG, SCREEN
log4perl.appender.SCREEN=Log::Log4perl::Appender::ScreenColoredLevels
log4perl.appender.SCREEN.stderr=1
log4perl.appender.SCREEN.layout=Log::Log4perl::Layout::PatternLayout
log4perl.appender.SCREEN.layout.ConversionPattern=[%P] %p [%c] %m%n

In one of the controllers (MintApp::Controller::Pub) I have a line:

    print STDERR "CALLED!\n";
    $c->log->debug ("Pub::begin: " . Dumper ($c->session));

For some reason, this is the output I get when calling the controller
MintApp::Controller::Pub :

CALLED!
[8517] DEBUG [MintApp.Controller.Pub] Pub::begin: $VAR1 = {
          '__created' => 1199713585,
          '__updated' => 1199713585
        };
[8517] DEBUG [MintApp.Controller.Pub] Pub::begin: $VAR1 = {
          '__created' => 1199713585,
          '__updated' => 1199713585
        };
[8517] DEBUG [MintApp.Controller.Pub] Pub::begin: $VAR1 = {
          '__created' => 1199713585,
          '__updated' => 1199713585
        };


As you can see from the output, for some reason the logger decides to
log several times, even though the logger is/should be only called once.
If I remove the two first lines in the logger configuration file, it
works fine.

It looks like the logger is getting confused with having different
settings for parts of the code, and when/if a log is triggered for one
level it outputs it for all levels defined.

I'm using Catalyst::Log::Log4perl version 1.00.

I tried briefly looking into the source, when I ran into this:

                # I really have no idea why the correct subroutine
                # is on a different call stack
                $caller{subroutine} = ( caller(1) )[3];    #wtf?

Does anybody want to comment on the maturity of the Catalyst log4perl
module?

Thanks,

Marius K.




More information about the Catalyst mailing list