Log4j Appender executing ONLY at a given level...

S

schmen

Is there a way to provide a log4j configuration that provides a
stipulation that a given appender executes ONLY at a given priority
level. For example, I have an SMTP appender that I would like to
execute only at the level of ERROR; and not at any of the lower
levels.

Currently, I have a decorator class to swap the appender in and out
depending on the level being invoked. Further, I plan on migrating
to the commons-logger project, that is why I would like for a solution
to be on the configuration side of things.

Any ideas would be appreciated.
 
D

David Hilsee

schmen said:
Is there a way to provide a log4j configuration that provides a
stipulation that a given appender executes ONLY at a given priority
level. For example, I have an SMTP appender that I would like to
execute only at the level of ERROR; and not at any of the lower
levels.

Currently, I have a decorator class to swap the appender in and out
depending on the level being invoked. Further, I plan on migrating
to the commons-logger project, that is why I would like for a solution
to be on the configuration side of things.

Any ideas would be appreciated.

Using the XML config file, you can specify filters so your logs only contain
certain levels. It sounds like you need to look at the LevelRangeFilter and
LevelMatchFilter. Google provides some examples of this (e.g.
http://www.mail-archive.com/[email protected]/msg10238.html).
Is this what you want?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top