On Aug 1, 2007, at 5:16 PM, Walter Holladay wrote:

Hi,

I work on a large project that has lots of logging information being written to the log file. I want to narrow what logging data I see to only those messages logged by my team mates. The way I would like to do this is by having a filter that will only pass through messages logged from a given logger, or loggers. All of the loggers at my company are created using the
class  that is doing the logging. For example private Logger logger =
Logger.getLogger(getClass()). Therefore, I would like to be able to specify the class or the package that the logger belongs to, and only have those
messages go to my log file.

I would think this is a fairly common thing to do. However, I cannot find a
filter that does this. Is there some way to accomplish this, short of
writing my own filter?

Thanks,
Walter


It is by far more common and efficient to use thresholds than filters for the scenario you described. Thresholds are used to discard logging requests prior to the creation of a LoggingEvent, filters are only applied after the LoggingEvent is created.

You could set the threshold on the root logger to something high (ERROR, FATAL or OFF) and the threshold to logger corresponding to your package or class of interest to something lower like DEBUG or INFO. All of that should be covered http://logging.apache.org/log4j/ docs/manual.html.

If you really did need to use a filter, there are two different classes (ExpressionFilter and LoggerMatchFilter) in the log4j extras companion (not yet released, but release candidates are available) that can filter on logger name.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to