Hi Monks,

I am looking at replacing our existing logging mechanism with Log::Log4perl.

The current mechanism is very simple. We have a base class that all classes inherit from. That class defines 2 methods - ->feedback and ->notify. The ->feedback method outputs to stdout and ->notify outputs to stderr.

I was hoping to set up Log4perl with a default initialisation file to mimic the current functionality (for backward compatibility) while allowing projects to take advantage of the power of Log4perl at their leisure.

Here is my initial stab at a config file ...

log4perl.rootLogger=DEBUG, LogFile, StdErr, StdOut log4perl.appender.LogFile=Log::Dispatch::File log4perl.appender.LogFile.name=file log4perl.appender.LogFile.filename=/project/xxx/log/plx.log log4perl.appender.LogFile.mode=append log4perl.appender.LogFile.min_level=error log4perl.appender.LogFile.layout=PatternLayout log4perl.appender.LogFile.layout.ConversionPattern=%-5p[%P]%d{yyyyMMdd + HH:mm:ss.SSSSSS} %m [%F line %L]%n log4perl.appender.StdErr=Log::Dispatch::Screen log4perl.appender.StdErr.name=stderr log4perl.appender.StdErr.stderr=1 log4perl.appender.StdErr.min_level=error log4perl.appender.StdErr.layout=PatternLayout log4perl.appender.StdErr.layout.ConversionPattern=[%P]%d{yyyyMMdd HH:m +m:ss.SSSSSS} %m%n log4perl.appender.StdOut=Log::Dispatch::Screen log4perl.appender.StdOut.name=stdout log4perl.appender.StdOut.stderr=0 log4perl.appender.StdOut.min_level=debug log4perl.appender.StdOut.max_level=warning log4perl.appender.StdOut.layout=PatternLayout log4perl.appender.StdOut.layout.ConversionPattern=[%P]%d{yyyyMMdd HH:m +m:ss.SSSSSS} %m%n
The question I have is to do with Log4perl levels and their corresponding Log::Dispatch levels. From what I can see, the 'lowest' level for Log::Dispatch is 'warning', whereas the lowest level for Log4perl is trace. Using the above config file, I was hoping to have anything output via ->warn, ->debug, ->info, or ->trace to be output to stdout. I can't seem to get ->trace messages to appear on stdout.

Any clues (or comments on my implementation)?

Thanks


In reply to Implementing Log::Log4perl by horrendo

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.