horrendo has asked for the wisdom of the Perl Monks concerning the following question:
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 ...
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.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
Any clues (or comments on my implementation)?
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Implementing Log::Log4perl
by tilly (Archbishop) on Aug 11, 2008 at 03:18 UTC | |
by horrendo (Sexton) on Aug 11, 2008 at 03:38 UTC | |
|
Re: Implementing Log::Log4perl
by saintmike (Vicar) on Aug 13, 2008 at 00:56 UTC |