log4perl autoflush (buffering log output?)

View: New views
2 Messages — Rating Filter:   Alert me  

log4perl autoflush (buffering log output?)

by Adam Bartosik-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have log4perl configured that way:

log4perl.appender.SCREEN=Log::Log4perl::Appender::Screen
log4perl.appender.SCREEN.layout=Log::Log4perl::Layout::PatternLayout
log4perl.appender.SCREEN.layout.ConversionPattern = %d{hh:mm:ss}> %m%n
log4perl.appender.SCREEN.autoflush = 1

and there is a controller which looks like:

sub test123 : Local {
    my ($self, $c) = @_;
    $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@...
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/

Re: log4perl autoflush (buffering log output?)

by Oleg Pronin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 = shift;
    $self->SUPER::_log(@_);
    $self->_flush if scalar(caller(1)) =~ /^MyApp(::|$)/;
}



 
2007/9/11, Adam Bartosik <moldovenu@...>:
I have log4perl configured that way:

log4perl.appender.SCREEN=Log::Log4perl::Appender::Screen
log4perl.appender.SCREEN.layout=Log::Log4perl::Layout::PatternLayout
log4perl.appender.SCREEN.layout.ConversionPattern = %d{hh:mm:ss}> %m%n
log4perl.appender.SCREEN.autoflush = 1

and there is a controller which looks like:

sub test123 : Local {
   my ($self, $c) = @_;
   $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@...
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/


_______________________________________________
List: Catalyst@...
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/