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

${varname}
afterwards to recall the assigned values. Here's an example:
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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.