使用 SMTPAppender 我只收到 ERROR 而不是 INFO 类型的日志项
我已经在我的 Java 应用程序中配置了 SMTPAppender。
<appender name="AdministratorEmail" class="org.apache.log4j.net.SMTPAppender">
<param name="Threshold" value="info" />
<param name="BufferSize" value="512" />
<param name="SMTPHost" value="smtp.sss.intranet" />
<param name="From" value="[email protected]" />
<param name="To" value="[email protected]" />
<param name="Subject" value="errors" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}]%n%n%-5p%n%n%c%n%n%m%n%n" />
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="info" />
<param name="LevelMax" value="fatal" />
</filter>
</appender>
我只收到 ERROR 日志类型,而不收到 INFO 类型!我更改了LevelMin,但什么也没有,我插入了Thresold,但什么也没有!
有人有什么建议吗?
I've configured an SMTPAppender into my Java app.
<appender name="AdministratorEmail" class="org.apache.log4j.net.SMTPAppender">
<param name="Threshold" value="info" />
<param name="BufferSize" value="512" />
<param name="SMTPHost" value="smtp.sss.intranet" />
<param name="From" value="[email protected]" />
<param name="To" value="[email protected]" />
<param name="Subject" value="errors" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}]%n%n%-5p%n%n%c%n%n%m%n%n" />
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="info" />
<param name="LevelMax" value="fatal" />
</filter>
</appender>
I receive only the ERROR log type and not the INFO type! I changed the LevelMin but nothing, I inserted the Thresold, but nothing!
Does someone have any kind of suggestion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SMTPAppender 按设计仅记录 ERROR 及以上消息。该等级不受属性影响。附加文档说明:
请参阅: Class SMTPAppender
事实上,您仅在第一个 ERROR 之后才看到 INFO 消息,这是由于 bufferSize 造成的属性,显示错误之前的“n”个最新日志行,以提供错误的上下文。
对此的进一步研究表明,“额外伴侣”中有 TriggerEventEvaluator 所需接口的实现,
可以从以下位置下载:Apache 下载镜像
如果您将其包含在项目中,则可以将以下内容添加到 log4j.xml 中的 SMTPAppender 定义中(注意不支持属性格式!)
The SMTPAppender by design only logs ERROR and above messages. This level cannot be affected by properties. The documentation for the appended states:
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!)