获取实时Log4J消息 [英] Get live Log4J messages

查看:121
本文介绍了获取实时Log4J消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在中央类中获取log4j所写的内容,以监视应用程序中的所有log4j日志?

How do I get what is being written by log4j in central class which monitors all log4j logs in the application?

谢谢

编辑:我希望我不必从日志文件中读取它,因为它会使用更多资源

I wish I would not have to read it from the log file since it would use more resources

推荐答案

您可以实现自己的 Appender 和使用普通配置复制所有日志:

You can implement your own Appender and copy all logs on it using the normal config:

log4j.rootLogger=WARN, file, other

log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=${catalina.home}/logs/log.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %p %t %c - %m%n

log4j.appender.other=class.path.of.your.Appender

这篇关于获取实时Log4J消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆