[Catalyst] RE: Log::Log4perl::Catalyst
Anthony Gladdish
anthony.gladdish at newcastle.ac.uk
Wed May 15 16:09:52 GMT 2013
Hi Duncan,
I overcame the hardcoding of filenames by storing them in the app config, like so:
In your MyApp.pm:
__PACKAGE__->setup;
__PACKAGE__->log( Log::Log4perl::Catalyst->new( __PACKAGE__->path_to(__PACKAGE__->config->{path_to_log4perl_conf})->stringify ) );
Then in the main app config:
path_to_log4perl_conf: 'Log4perl_prod.conf'
Log4Perl_filename: '/some/path/to/logfile.log'
Then in ./Log4perl_prod.conf (root of the Cat app):
log4perl.appender.LOGFILE.filename=sub { return MyApp->config->{Log4Perl_filename} }
Hope this helps,
Anthony Gladdish
From: Duncan Garland [mailto:Duncan.Garland at motortrak.com]
Sent: 15 May 2013 16:54
To: catalyst at lists.scsys.co.uk
Subject: [Catalyst] Log::Log4perl::Catalyst
Hi,
Has anybody got some examples about how to use this.
It looks like you just have to put the following lines in the main package before __PACKAGE__->setup():
use Log::Log4perl::Catalyst;
__PACKAGE__->log(Log::Log4perl::Catalyst->new('/path/to/log4perl.conf'));
That works up to a point in that the log messages are formatted as I want. However they always go to the STDERR and not to the file given in log4perl.conf. I've used the conf file in a test, so I know it works outside Catalyst. I'm using the Catalyst development server, does that over-ride the logger?
The other thing is that I don't really want to hardcode the filename. It should be in the application's conf file. However, if I just stick it in there as so:
<Log4perl>
conf_file /var/www/mymercedesservice.co.uk/fcgi/catalyst/mbfl2/lib/mbfl2/log4perl.conf
</Log4perl>
I can't access it via __PACKAGE__->config->{Log4perl}->{conf_file};
until after setup() has run.
Does that matter?
Thanks
Duncan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20130515/44235c95/attachment.htm
More information about the Catalyst
mailing list