There's a gotcha: If you're using "STDOUT" as the 'file' parameter,
easy_init() creates a Screen appender, not a File appender -- hence you
can't call file_switch() on it.
I'd recommend using a standard l4p init file (or string) to define
exactly what kind of appender you want (File in this case).
-- Mike
Mike Schilli
m...@pe...
On Mon, 23 Mar 2009, Ronald Fischer wrote:
> I finally found the time to implement the solution for switching logfiles at run-time
> (see my posting "Re: Appender::File and Layout question" from March 6), but now
> I am facing a new problem: Perl (ActivePerl 5.8 on Windows) crashes when I try to
> switch the file.
>
> Here is the example code:
>
> 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'
> },
> );
>
> ...
>
> # Switch 'requestlogger' to new file
> Log::Log4perl->appender_by_name('requestlogger')->file_switch('request_specific.log');
>
> At this point, Perl complains:
>
> "Can't call method "file_switch" on an undefined value"
>
> If I change the line so that it uses the default appender name,
>
> Log::Log4perl->appender_by_name('app002')->file_switch('request_specific.log');
>
> it works. It seems that easy_init does not use the "name" parameter. Is this a bug in easy_init,
> or is it supposed to work that way?
>
> Ronald
>
>
> --
> Ronald Fischer <ro...@em...>
> + 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)
>
>
> ------------------------------------------------------------------------------
> Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
> powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
> easily build your RIAs with Flex Builder, the Eclipse(TM)based development
> software that enables intelligent coding and step-through debugging.
> Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
> _______________________________________________
> log4perl-devel mailing list
> log...@li...
> https://lists.sourceforge.net/lists/listinfo/log4perl-devel
>
|