[logback-user] log4j StringMatchFilter porting to logback
Ceki Gülcü
ceki at qos.ch
Tue Feb 22 18:11:37 CET 2011
On 22/02/2011 5:47 PM, Fabio Erculiani wrote:
> Hi there, it's me again,
> just wondering, what's the best way to reproduce the behaviour of
> log4j StringMatchFilter in logback?
> Do I have to use ch.qos.logback.core.filter.EvaluatorFilter ?
You can re-write StringMatchFilter by extending Filter or
AbstractMatcherFilter classes both located in the
ch.qos.logback.core.filter package.
You could also learn to use EvaluatorFilter with GEventEvaluator (takes
an expression in Groovy) or JaninoEventEvaluator (takes an expression in
Java. See [1] for details.
Re-writing StringMatchFilter should be rather easy and will not require
any other dependencies. Using JaninoEventEvaluator will require Janino
and GEventEvaluator will require the Groovy runtime. However,
JaninoEventEvaluator/GEventEvaluator are much easier to extend should
your needs go beyond just string matching on the log message.
HTH,
--
Ceki
[1] http://logback.qos.ch/manual/filters.html#evalutatorFilter
More information about the Logback-user
mailing list