shamu has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I have two modules:

I'm trying to get the following to happen:

  1. Log all INFO (and above) messages to run.log
  2. Only log ERROR messages from AA::Log to error.log and no where else.

I'm trying to use the additivity flag in Syncer2 to prevent ERROR messages from being passed up the hierarchy. It does not seem to work - ERROR messages from AA::Log are being sent to AA. Any ideas?

log4perl.logger.AA = INFO, Syncer1 log4perl.logger.AA.Log = INFO, Syncer2 log4perl.filter.MatchError = Log::Log4perl::Filter::LevelMatch log4perl.filter.MatchError.LevelToMatch = ERROR log4perl.filter.MatchError.AcceptOnMatch = true log4perl.appender.Syncer1 = Log::Dispatch:: +FileShared log4perl.appender.Syncer1.name = run.log log4perl.appender.Syncer1.filename = run.log log4perl.appender.Syncer1.layout = Log::Log4perl:: +Layout::PatternLayout log4perl.appender.Syncer1.layout.ConversionPattern = %P %d{yyyy-MM-d +d HH:mm:ss}: %m%n log4perl.appender.Syncer2 = Log::Dispatch:: +FileShared log4perl.appender.Syncer2.name = error.log log4perl.appender.Syncer2.filename = error.log log4perl.appender.Syncer2.layout = Log::Log4perl:: +Layout::PatternLayout log4perl.appender.Syncer2.layout.ConversionPattern = %m%n log4perl.appender.Syncer2.Filter = MatchError log4perl.appender.Syncer2.additivity = 0

Thanks!

Replies are listed 'Best First'.
Re: Log::Log4perl additivity not working?
by Anonymous Monk on Apr 28, 2007 at 04:06 UTC
    $perldoc Log::Log4perl::Config|grep additivity The additivity flag of a logger is set or cleared via the "additiv +ity" log4perl.additivity.Bar.Twix = 0|1 dilemma that a logger name could end in ".additivity" according to + the $

      Though the solution of using additivity will prevent any ERROR level messages from passing up the hierarchy, it also prevents all other messages from passing too.

      How can I pass everything except the ERROR level messages, from a nested category, up the hierarchy?