[Catalyst] using Catalyst with Log::Log4perl

Ian.Docherty at nomura.com Ian.Docherty at nomura.com
Fri Jun 24 17:07:18 GMT 2011


Hello

I have tried both Log::Log4perl::Catalyst and Catalyst::Log::Log4perl and neither of them refer to using the same logger both inside and outside of the Catalyst namespace.

For example, if I have some classes that are shared by both Catalyst and command-line tools and I want to put logging in them.

I have this in my (none) Catalyst classes.

package MyApp::Foo;
use Log::Log4perl; 
sub bar {
    my $log = Log::Log4perl->get_logger();
    $log->debug("this is not in Catalyst");
}

I have this in my Catalyst classes.

package MyApp::Web::Controller::Root;
sub boo {
    my ($self, $c) = @_;

    $c->log->debug("This *is* in Catalyst");
}

In order to get this to work I have to do the following in MyApp/Web.pm

__PACKAGE__->log(Log::Log4perl::Catalyst->new('myapp_web.log4perl.conf'));
Log::Log4perl->init('myapp_web.log4perl.conf');

Is this how anyone else does it or am I missing some other way of combining the two?

Regards
Ian




This e-mail (including any attachments) is confidential, may contain
proprietary or privileged information and is intended for the named
recipient(s) only. Unintended recipients are prohibited from taking action
on the basis of information in this e-mail and must delete all copies.
Nomura will not accept responsibility or liability for the accuracy or
completeness of, or the presence of any virus or disabling code in, this
e-mail. If verification is sought please request a hard copy. Any reference
to the terms of executed transactions should be treated as preliminary only
and subject to formal written confirmation by Nomura. Nomura reserves the
right to monitor e-mail communications through its networks (in accordance
with applicable laws). No confidentiality or privilege is waived or lost by
Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is
a reference to any entity in the Nomura Holdings, Inc. group. Please read
our Electronic Communications Legal Notice which forms part of this e-mail:
http://www.Nomura.com/email_disclaimer.htm




More information about the Catalyst mailing list