Re: [Catalyst] Log::Log4perl::Catalyst

2013-05-15 Thread Alexander Hartmaier
On 2013-05-15 17:54, Duncan Garland wrote:
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

That's how I do it in all of our Catalyst apps:

In My::App:

=item finalize_config

Initializes the logger after the config file merging and loading is done.

=cut

sub finalize_config {
my $class = shift;
$class-next::method(@_);
$class-log(Log::Log4perl::Catalyst-new($class-config-{log}));
}

# Start the application
__PACKAGE__-setup;

around 'prepare' = sub {
my $orig = shift;
my $self = shift;

Log::Log4perl::MDC-remove();

my $c = $self-$orig(@_);

Log::Log4perl::MDC-put( username, $c-user-username )
if $c-user_exists;

return $c;
};

This assumes that the l4p config is in the app config file under 'log' e.g. 
from one of my Config::General config files:

log
log4perl.logger WARN, FILE, MAIL
log4perl.appender.FILE  
Log::Log4perl::Appender::File
log4perl.appender.FILE.filename 
/home/nac/log/nac-web-request.log
log4perl.appender.FILE.utf8 1
log4perl.appender.FILE.syswrite 1
log4perl.appender.FILE.layout   
Log::Log4perl::Layout::PatternLayout
log4perl.appender.FILE.layout.ConversionPattern %d{-MM-dd 
HH:mm:ss} %-5p %X{username} %m%n
log4perl.appender.MAIL  
Log::Dispatch::Email::MailSend
log4perl.appender.MAIL.ThresholdERROR
log4perl.appender.MAIL.from 
a...@t-systems.atmailto:a...@t-systems.at
log4perl.appender.MAIL.to   
poor.bastard-aka...@ourcompany.commailto:poor.bastard-aka...@ourcompany.com
log4perl.appender.MAIL.subject  [NAC::Web::Request] 
errors
log4perl.appender.MAIL.buffered 0
log4perl.appender.MAIL.layout   PatternLayout
log4perl.appender.MAIL.layout.ConversionPattern %d{-MM-dd 
HH:mm:ss} %-5p %X{username} %m%n
/log





___
List: Catalyst@lists.scsys.co.ukmailto:Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/




***
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
***
Notice: This e-mail contains information that is confidential and may be 
privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
***
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Log::Log4perl::Catalyst or Catalyst::Log::Log4perl ?

2010-06-14 Thread Peter Corlett
On Sun, Jun 13, 2010 at 11:14:44AM +0200, Christiaan Kras wrote:
[...]
 I've found and tried Catalyst::Plugin::Log4perl::Simple but when using the
 module Catalyst warns about it using NEXT. So I'm wondering if it's smart
 to use it in its current state.

That's one of my modules, a very crude hack to scratch one of my itches.
Although it gives a warning, it does work. It didn't give a warning when I
wrote it, but CPAN has marched on.

Since the warning's annoying me, I'll probably fix it over the next week or
so.


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


Re: [Catalyst] Log::Log4perl::Catalyst or Catalyst::Log::Log4perl ?

2010-06-14 Thread Tomas Doran


On 13 Jun 2010, at 18:53, J. Shirley wrote:



On Jun 13, 2010, at 3:56 AM, Christiaan Kras wrote:


Thanks. He suggests Catalyst::Log::Log4perl.
I guess I'll try both Catalyst::Log::Log4perl and  
Log::Log4perl::Catalyst then.


Christiaan Kras


The cspec issues can (in most cases) be safely ignored.


There are patches to fix them (by removing most of the code) pending,  
but I haven't found the tuits to finish it yet..


If you do encounter any issues with using it, please let me know  
what they are and I'll work towards getting them fixed up.


Ditto.

It does, however, look like the autoflush issue needs to be  
resolved.  I'll see if I can get the tuits to chase that down next  
week.


There are pending patches for a load of things - I haven't had the  
time to maintain it that it deserves recently, so if anyone else is  
prepared to help work on it I'd be entirely glad.


I can say that it does work for me in production, and I do have some  
plans to get back to it (as I need to do some work on logging in  
various of my apps some time in the next couple of months)...


Cheers
t0m


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


Re: [Catalyst] Log::Log4perl::Catalyst or Catalyst::Log::Log4perl ?

2010-06-13 Thread David Schmidt
On Sun, Jun 13, 2010 at 11:14 AM, Christiaan Kras c.k...@pcc-online.net wrote:
 Hi list,

 I'm currently looking at the available modules for implementing
 Log::Log4perl with my Catalyst app and would like to have some advice on it.

 I've found and tried Catalyst::Plugin::Log4perl::Simple but when using the
 module Catalyst warns about it using NEXT. So I'm wondering if it's smart to
 use it in its current state.

 When looking on I also found Log::Log4perl::Catalyst and
 Catalyst::Log::Log4perl. Where the former is part of the Log::Log4perl
 distribution. The latter still has some old issues open on which the author
 hasn't responded yet. So to me it seems abandoned. Other than that I don't
 really see much difference between both modules. I must note though that the
 former is very new and is only available since 2010/02/24

 From this I'd say using Log::Log4perl::Catalyst is the way to go: it's part
 of the Log::Log4perl distribution and has no open bugs (at least not on the
 Catalyst module).

 Thanks.

 --

 Christiaan Kras

 http://blog.htbaa.com
 http://www.brandweeruren.nl


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


Check whichever Plugin for log4perl Jay Shirley is recommending in
this talk and go with it.

http://www.presentingperl.org/opw2010/zen-maintenance/

greetings
david


-- 
David Schmidt   |   http://www.fm5.at

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


Re: [Catalyst] Log::Log4perl::Catalyst or Catalyst::Log::Log4perl ?

2010-06-13 Thread Christiaan Kras

Thanks. He suggests Catalyst::Log::Log4perl.
I guess I'll try both Catalyst::Log::Log4perl and 
Log::Log4perl::Catalyst then.


Christiaan Kras

http://blog.htbaa.com
http://www.brandweeruren.nl


Op 13-6-2010 11:42, David Schmidt schreef:

On Sun, Jun 13, 2010 at 11:14 AM, Christiaan Krasc.k...@pcc-online.net  wrote:
   

Hi list,

I'm currently looking at the available modules for implementing
Log::Log4perl with my Catalyst app and would like to have some advice on it.

I've found and tried Catalyst::Plugin::Log4perl::Simple but when using the
module Catalyst warns about it using NEXT. So I'm wondering if it's smart to
use it in its current state.

When looking on I also found Log::Log4perl::Catalyst and
Catalyst::Log::Log4perl. Where the former is part of the Log::Log4perl
distribution. The latter still has some old issues open on which the author
hasn't responded yet. So to me it seems abandoned. Other than that I don't
really see much difference between both modules. I must note though that the
former is very new and is only available since 2010/02/24

 From this I'd say using Log::Log4perl::Catalyst is the way to go: it's part
of the Log::Log4perl distribution and has no open bugs (at least not on the
Catalyst module).

Thanks.

--

Christiaan Kras

http://blog.htbaa.com
http://www.brandweeruren.nl


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

 

Check whichever Plugin for log4perl Jay Shirley is recommending in
this talk and go with it.

http://www.presentingperl.org/opw2010/zen-maintenance/

greetings
david


   


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


Re: [Catalyst] Log::Log4perl::Catalyst or Catalyst::Log::Log4perl ?

2010-06-13 Thread J. Shirley

On Jun 13, 2010, at 3:56 AM, Christiaan Kras wrote:

 Thanks. He suggests Catalyst::Log::Log4perl.
 I guess I'll try both Catalyst::Log::Log4perl and Log::Log4perl::Catalyst 
 then.
 
 Christiaan Kras

The cspec issues can (in most cases) be safely ignored.

If you do encounter any issues with using it, please let me know what they are 
and I'll work towards getting them fixed up.

It does, however, look like the autoflush issue needs to be resolved.  I'll see 
if I can get the tuits to chase that down next week.

Thanks,
-Jay
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


RE: [Catalyst] Log::Log4perl::Catalyst or Catalyst::Log::Log4perl ?

2010-06-13 Thread Christiaan Kras
So far I haven't run into any issues. My app isn't production ready either so 
it doesn't receive much traffic either.

-origineel bericht-
Onderwerp: Re: [Catalyst] Log::Log4perl::Catalyst or Catalyst::Log::Log4perl ?
Van: J. Shirley jshir...@gmail.com
Datum: 13-06-2010 19:57


On Jun 13, 2010, at 3:56 AM, Christiaan Kras wrote:

 Thanks. He suggests Catalyst::Log::Log4perl.
 I guess I'll try both Catalyst::Log::Log4perl and Log::Log4perl::Catalyst 
 then.
 
 Christiaan Kras

The cspec issues can (in most cases) be safely ignored.

If you do encounter any issues with using it, please let me know what they are 
and I'll work towards getting them fixed up.

It does, however, look like the autoflush issue needs to be resolved.  I'll see 
if I can get the tuits to chase that down next week.

Thanks,
-Jay
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


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