with SMTPAppender I receive only ERROR and not INFO type of log items

后端 未结 1 1314
Happy的楠姐
Happy的楠姐 2020-12-29 14:30

I\'ve configured an SMTPAppender into my Java app.


  

        
1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-29 15:17

    The SMTPAppender by design only logs ERROR and above messages. This level cannot be affected by properties. The documentation for the appended states:

    By default, an email message will be sent when an ERROR or higher severity message is appended. The triggering criteria can be modified by setting the evaluatorClass property with the name of a class implementing TriggeringEventEvaluator, setting the evaluator property with an instance of TriggeringEventEvaluator or nesting a triggeringPolicy element where the specified class implements TriggeringEventEvaluator

    See: Class SMTPAppender

    The fact that you are seeing INFO messages only after the first ERROR is due to the bufferSize property which shows the 'n' most recent log lines before the error to give context to the error.

    Further research on this shows that there is an implementation of the required interface for TriggerEventEvaluator in the 'extras companion'

    This can be downloaded from: Apache Download Mirrors

    If you include this in your project you can then add the following to your SMTPAppender definition in log4j.xml (note the properties format is not supported!)

      
    ...
        
          
            
          
        
    ...
      
    

    0 讨论(0)
提交回复
热议问题