I'm feeling some sort of 'O'Reilly tribute' <Saint Patty's just passed>
Happy St. Patty's (I'm actually a tad late, somewhere)I have always found that to be an excellent log4perl article series, but as I refer to it I can't seem to see any reference to it. Here's a better source:
Variable Substitution (are you not a troll? :L)
" To avoid having to retype the same expressions over and over again, Log::Log4perl's configuration files support simple variable substitution. New variables are defined simply by adding
varname = value
lines to the configuration file before using
afterwards to recall the assigned values. Here's an example:${varname}
layout_class = Log::Log4perl::Layout::PatternLayout layout_pattern = %d %F{1} %L> %m %n log4perl.category.Bar.Twix = WARN, Logfile, Screen log4perl.appender.Logfile = Log::Log4perl::Appender::File log4perl.appender.Logfile.filename = test.log log4perl.appender.Logfile.layout = ${layout_class} log4perl.appender.Logfile.layout.ConversionPattern = ${layout_patt +ern} log4perl.appender.Screen = Log::Log4perl::Appender::Screen log4perl.appender.Screen.layout = ${layout_class} log4perl.appender.Screen.layout.ConversionPattern = ${layout_patte +rn}
This is a convenient way to define two appenders with the same layout without having to retype the pattern definitions.
Update:
After rereading your post (I tend to do that) I think that perhaps this more inline with what you're getting at. This is analagous to writing log4perl eval statment - pick your favourite Templater for flavour. Kurt
Dirty Tricks Example (Sorry about the Troll comment :))
A simple example to cut-and-paste and get started:
use Log::Log4perl qw(get_logger); my $conf = q( log4perl.category.Bar.Twix = WARN, Logfile log4perl.appender.Logfile = Log::Log4perl::Appender::File log4perl.appender.Logfile.filename = test.log log4perl.appender.Logfile.layout = \ Log::Log4perl::Layout::PatternLayout log4perl.appender.Logfile.layout.ConversionPattern = %d %F{1} %L> +%m %n ); Log::Log4perl::init(\$conf); my $logger = get_logger("Bar::Twix"); $logger->error("Blah");
This will log something like:
2002/09/19 23:48:15 t1 25> Blah
to the log file 'test.log', which Log4perl will append to or create it if it doesn't exist already.
In reply to Re: Accessing Log::Log4perl Configuration Values
by whereiskurt
in thread Accessing Log::Log4perl Configuration Values
by valdez
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |