解析一个 log4j 日志文件 [英] Parse a log4j log file

查看:29
本文介绍了解析一个 log4j 日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有几个使用 log4j 进行日志记录的应用程序.我需要让 log4j 解析器正常工作,以便我们可以组合多个日志文件并对它们运行自动分析.我不想重新发明轮子,所以有人可以指出我一个体面的预先存在的解析器吗?如果有帮助,我确实有 log4j 转换模式.

We have several applications that use log4j for logging. I need to get a log4j parser working so we can combine multiple log files and run automated analysis on them. I'm not looking to reinvent the wheel, so can someone point me to a decent pre-existing parser? I do have the log4j conversion pattern if that helps.

如果没有,我将不得不自己动手.

If not, I'll have to roll our own.

推荐答案

我没有意识到 Log4J 附带了一个 XML 附加程序.

I didn't realize that Log4J ships with an XML appender.

解决方案是:在日志配置文件中指定一个 XML appender,将该输出 XML 文件作为一个实体包含到一个格式良好的 XML 文件中,然后使用您喜欢的技术解析 XML.

Solution was: specify an XML appender in the logging configuration file, include that output XML file as an entity into a well formed XML file, then parse the XML using your favorite technique.

其他方法有以下限制:

  • Apache Chainsaw - 不够自动化
  • jdbc - 在高性能分布式应用中性能不佳

这篇关于解析一个 log4j 日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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