[Catalyst] log4perl autoflush (buffering log output?)

Oleg Pronin syber.rus at gmail.com
Wed Sep 12 17:05:29 GMT 2007


I use this hack to disable buffering for MyApp code (not for Catalyst core).

package MyApp;

__PACKAGE__->log( MyApp::Log->new );

package MyApp::Log;
use strict;
use base 'Catalyst::Log';

sub _log {
    my $self =3D shift;
    $self->SUPER::_log(@_);
    $self->_flush if scalar(caller(1)) =3D~ /^MyApp(::|$)/;
}



2007/9/11, Adam Bartosik <moldovenu at gmail.com>:
>
> I have log4perl configured that way:
>
> log4perl.appender.SCREEN=3DLog::Log4perl::Appender::Screen
> log4perl.appender.SCREEN.layout=3DLog::Log4perl::Layout::PatternLayout
> log4perl.appender.SCREEN.layout.ConversionPattern =3D %d{hh:mm:ss}> %m%n
> log4perl.appender.SCREEN.autoflush =3D 1
>
> and there is a controller which looks like:
>
> sub test123 : Local {
>    my ($self, $c) =3D @_;
>    $c->log->debug("time: " . localtime );
>    sleep 5;
>    $c->log->debug("time: " . localtime );
>    $c->res->body("ok");
> }
>
> but the console output is like:
> 12:50:46> time: Tue Sep 11 12:50:40 2007
> 12:50:46> time: Tue Sep 11 12:50:45 2007
>
> Log time from log4perl is the same for all debug messages :(
>
> I know there are problems (and patches) to show proper line/module
> where log event occured with log4perl. What about this log-event time?
>
> --
> Adam Bartosik
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070912/1eac4=
482/attachment.htm


More information about the Catalyst mailing list