Because the Log4perl configuration file format requires each configuration item to be on a single line. You can continue a line onto the next line by ending it in a backslash, or you can just type it out as one really long line. If you review the documentation on CPAN again, you will notice that all of the examples use very short subs, and none of them span more than one line.
The method I normally use for approaching this is something like...
# config file
log4perl.logger.ClassA = DEBUG, ClassA
log4perl.appender.ClassA = Log::Log4perl::Appender::File
log4perl.appender.ClassA.filename = sub { log_filename() }
# in the main code
use POSIX 'strftime';
sub log_filename {
return strftime( "/tmp/ClassA%Y%m%d.log", localtime );
}
Log::Log4perl::init_and_watch('/etc/log4perl.conf',5);
my $mylog = Log::Log4perl->get_logger();
We're not surrounded, we're in a target-rich environment! |
---|
|