Yair Zaslavsky
Yair Zaslavsky

Reputation: 4137

Setting log4j filters programmatically


Today I learnt about the existence of log4j filters, and how I can set them in configuration file.
I have an Appender serving all the classes under a given package.
For one of these classes I would like to set a log4j filter which I will develop that will be based on StringMatchFilter (it will extend it).
For all the other classes I do not want to use this filter.
How can this be obtained?

Upvotes: 1

Views: 2306

Answers (1)

Yair Zaslavsky
Yair Zaslavsky

Reputation: 4137

I managed to dig a bit, and look at what might be the solution (still need to verify):
A. Obtain the Logger object
B. Call the getAppender method
C. For the obtained Appender, call addFilter

Upvotes: 2

Related Questions