Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

Configuration of $c->log with Catalyst::Log::Log4perl

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


skirnir at gmx

May 8, 2008, 7:42 AM

Post #1 of 7 (254 views)
Permalink
Configuration of $c->log with Catalyst::Log::Log4perl

Hi,

I'm trying to replace Catalyst's default logger with
Catalyst::Log::Log4perl.
Here's the relevant part of MyApp.pm:

package MyApp;

use strict;
use warnings;

use Catalyst::Runtime '5.70';

use Catalyst::Log::Log4perl;
use Catalyst qw/
-Debug
ConfigLoader
Static::Simple

StackTrace

Authentication
Authentication::Store::DBIC
Authentication::Credential::Password
Authorization::Roles
Authorization::ACL

Session
Session::Store::FastMmap
Session::State::Cookie

FormValidator
FillInForm
I18N
Unicode

Email

/;

use Sys::Hostname;
our $VERSION = '0.01';


__PACKAGE__->config( name => 'MyApp' );

__PACKAGE__->log( Catalyst::Log::Log4perl->new('myapp_logger.conf'));
__PACKAGE__->setup;

This is myapp_logger.conf:

log4perl.rootLogger=DEBUG, SCREEN

log4perl.appender.SCREEN=Log::Log4perl::Appender::Screen
log4perl.appender.SCREEN.mode=append

log4perl.appender.SCREEN.layout=PatternLayout
log4perl.appender.SCREEN.layout.ConversionPattern=[%d] %C <%p> - %m%n

After starting, the Conversion Pattern the logger actually uses looks like:

%d

Trying to find a minimal App producing the problem, I set up a Test
Application and provided
the same config file. There the logger works as expected.
Next I went through the logger configuration in the debugger with both
Apps up to:

Log::Log4perl::Config::BaseConfigurator::text(/usr/lib/perl5/vendor_perl/5.8.8/Log/Log4perl/Config/BaseConfigurator.pm:29):
29: $self->{text} = $text;

there I dumped $text which contained an array ref containing the lines
of the above cited config file (I saved both dumps to files, and diff
told me they were the same except for the numeric parts of the array
refs). Thus I think I can be quite sure that the logger is initialized
with the same config in both Apps.
Still, my original App comes up with the "%d" ConversionPattern.

So, can anyone tell me where I should continue looking for the error?
Can anyone think of a scenario where the logger config gets messed up
after initial configuration?

Thanks,

Jochen

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


mariusauto-catalyst at kjeldahl

May 8, 2008, 8:06 AM

Post #2 of 7 (229 views)
Permalink
Re: Configuration of $c->log with Catalyst::Log::Log4perl [In reply to]

Jochen Luig wrote:
> This is myapp_logger.conf:
>
> log4perl.rootLogger=DEBUG, SCREEN

Not sure if it changes anything, but does changing rootLogger to logger
help?

Sincerely,

Marius K.


_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


skirnir at gmx

May 8, 2008, 8:21 AM

Post #3 of 7 (230 views)
Permalink
Re: Configuration of $c->log with Catalyst::Log::Log4perl [In reply to]

Marius Kjeldahl schrieb:
> Not sure if it changes anything, but does changing rootLogger to
> logger help?
No, it neither changes the behaviour of the App's logger, nor did it
break the Test App's logger. In fact, I'd be surprised if it had to do
with the config as it already works as expected in the Test App.

Jochen

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


mariusauto-catalyst at kjeldahl

May 8, 2008, 9:26 AM

Post #4 of 7 (228 views)
Permalink
Re: Configuration of $c->log with Catalyst::Log::Log4perl [In reply to]

Jochen Luig wrote:
> log4perl.appender.SCREEN.layout=PatternLayout

How about changing PatternLayout to Log::Log4perl::Layout::PatternLayout?

(sorry, I have no real knowledge about these modules, I only compare
with what I have working at my end).

Marius K.


_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


jon+catalyst at youramigo

May 8, 2008, 5:34 PM

Post #5 of 7 (226 views)
Permalink
Re: Configuration of $c->log with Catalyst::Log::Log4perl [In reply to]

On Thu, 2008-05-08 at 16:42 +0200, Jochen Luig wrote:

> So, can anyone tell me where I should continue looking for the error?
> Can anyone think of a scenario where the logger config gets messed up
> after initial configuration?
>

If any part of your app invokes Log::Log4perl->easy_init(), that will
break it. There was such a line of code in a SQL::Translator file at
one stage, but it has been fixed in more recent versions.


--
Jon Schutz My tech notes http://notes.jschutz.net
Chief Technology Officer http://www.youramigo.com
YourAmigo


_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


jon+catalyst at youramigo

May 8, 2008, 10:54 PM

Post #6 of 7 (216 views)
Permalink
Re: Configuration of $c->log with Catalyst::Log::Log4perl [In reply to]

On Fri, 2008-05-09 at 10:04 +0930, Jon Schutz wrote:
> On Thu, 2008-05-08 at 16:42 +0200, Jochen Luig wrote:
>
> > So, can anyone tell me where I should continue looking for the error?
> > Can anyone think of a scenario where the logger config gets messed up
> > after initial configuration?
> >
>
> If any part of your app invokes Log::Log4perl->easy_init(), that will
> break it. There was such a line of code in a SQL::Translator file at
> one stage, but it has been fixed in more recent versions.
>

I take that back - the file in question is
SQL::Translator::Schema::Graph.pm and the call to easy_init() is still
there. There's a good chance this module is loaded if you are using
DBIx::Class and calling deploy() from your app.

Details in:
http://www.mail-archive.com/dbix-class[at]lists.rawmode.org/msg03436.html

--
Jon Schutz My tech notes http://notes.jschutz.net
Chief Technology Officer http://www.youramigo.com
YourAmigo


_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


skirnir at gmx

May 9, 2008, 1:24 AM

Post #7 of 7 (216 views)
Permalink
Re: Configuration of $c->log with Catalyst::Log::Log4perl [In reply to]

Jon Schutz schrieb:

>> If any part of your app invokes Log::Log4perl->easy_init(), that will
>> break it.

Yes, that was the problem.

Thanks!

Jochen

_______________________________________________
List: Catalyst[at]lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst[at]lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.