Pregunta

I have two appenders in my logging configuration. One of them sends E-Mail on ERROR Events.

A class, that I have no control over, spams ERROR messages. So I still want to have that messages but not in both appenders.

This is about my file (reduced to the stuff relevant here, afaics):

<appender name="Logfile">...</appender>
<appender name="sendMailOnError">...</appender>

<logger name="spammingClass">
    <level value="info"/>
</logger>

<root>
   <level value="debug"/>
   <appender-ref ref="Logfile"/>
   <appender-ref ref="sendMailOnError"/>
</root>

So, my guess is that I can somehow exclude spammingClass in sendMailOnError but I don't know how.

Btw. I use Java, but I would like to not write an own Filter class for this.

¿Fue útil?

Solución

Yes, by specifying appenders for spammingClass and setting additivity to false:

<logger name="spammingClass" additivity="false">
    <level value="info"/>
    <appender-ref ref="Logfile"/>
</logger>

Otros consejos

You can use additivity, in your example change the spammingClass logger to :

<logger name="spammingClass" additivity="false">
    <level value="info"/>
</logger>

and it will do the trick.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top