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

查看:101
本文介绍了解析一个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追加器,将输出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.

其他方法具有以下局限性:

The other methods had the following limitations:

  • Apache电锯-自动化程度不够
  • jdbc-高性能分布式应用程序中的性能不佳
  • Apache Chainsaw - not automated enough
  • jdbc - poor performance in a high performance distributed app

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

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