On Mon, 09 Mar 2009 12:09 -0700, "Mike Schilli" <m...@perlmeister.com> wrote: > A, gotcha, I forgot that you have a long-running process and want to > switch log files for every request. To do that, you can write your own > appender (it's very easy, check > http://search.cpan.org/dist/Log-Log4perl/lib/Log/Log4perl/FAQ.pm#How_can_I_write_my_own_appender?) > or, alternatively, when you get a request, run > > Log::Log4perl->appender_by_name("LogApp")->file_switch("log$$.log"); > > given that "LogApp" is the name of the appender in your Log4perl > configuration (if you're using :easy, its name is "app001").
I like the use of file_switch, because this seems to map perfectly well to the design I have right now. If I use easy_init like this: Log::Log4perl->easy_init( {level => $log_level, file => 'STDOUT', layout => '%.1p %d{HH:mm} %M(%L) %m%n' }, {level => $log_level, file => ">main.log", layout => '%.1p %d{dd.MM. HH:mm:ss (EEE)} %M(%L) %m%n' } {level => $log_level, file => '>dummy.log'), layout => '%.1p %d{HH:mm} %M(%L) %m%n' }, ); I guess the name of the "dummy.log" appender then is app003, so I would have to switch it by Log::Log4perl->appender_by_name('app003')->file_switch(get_request_logfile()); or alternatively that I explicitly provide logger names, i.e. Log::Log4perl->easy_init( {level => $log_level, file => 'STDOUT', layout => '%.1p %d{HH:mm} %M(%L) %m%n' }, {level => $log_level, file => ">main.log", layout => '%.1p %d{dd.MM. HH:mm:ss (EEE)} %M(%L) %m%n' } {level => $log_level, file => '>dummy.log'), layout => '%.1p %d{HH:mm} %M(%L) %m%n', name => 'requestlogger' }, ); ... Log::Log4perl->appender_by_name('requestlogger')->file_switch(get_request_logfile()); Is this correct? Regards, Ronald -- Ronald Fischer <rona...@eml.cc> + If a packet hits a pocket on a socket on a port, + and the bus is interrupted and the interrupt's not caught, + then the socket packet pocket has an error to report. + (cited after Peter van der Linden) ------------------------------------------------------------------------------ _______________________________________________ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel