是否可以使用 Chainsaw 读取日志文件?

发布于 2024-08-13 01:08:30 字数 238 浏览 3 评论 0原文

我有几个日志文件[通过 log4j 生成]。我知道我们可以使用 Chainsaw 来读取这些日志 [尽管我们可以读取这些日志也在记事本中]。
但我无法弄清楚如何打开存储的日志文件来查看其内容。所以简单的问题是,是否可以使用 Chainsaw 读取日志文件?

I am having several log files [ generated via log4j ]. I got to know that we can use Chainsaw to read those logs [ though we can reads those logs in notepad as well ].
But i am unable to figure out how to open a stored log file to see its content. So the simple question is, Is it possible to read the log file using Chainsaw?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

酒浓于脸红 2024-08-20 01:08:30

是的 - 只要每个日志条目以“消息”结尾并且以换行符分隔,您应该能够使用 LogFilePatternReceiver 解析日志文件。

日志行示例:

20100128 11:35:34.546 [main] INFO - package1.package2.SomeLoggerName - Message here line1
message here line2

这两行代表一个日志条目,可以使用以下日志格式进行解析:

TIMESTAMP [THREAD] LEVEL - LOGGER - MESSAGE

请参阅 LogFilePatternReceiver JavaDoc 以获取更多信息(可从 Chainsaw 的帮助菜单中获取)和示例接收器配置(可从欢迎选项卡,“查看示例接收器配置”按钮)。

Yes - as long as each log entry ends with the 'message' and is newline delimited, you should be able to parse the log file using LogFilePatternReceiver.

Example log line:

20100128 11:35:34.546 [main] INFO - package1.package2.SomeLoggerName - Message here line1
message here line2

These two lines, representing one log entry, can be parsed with this logFormat:

TIMESTAMP [THREAD] LEVEL - LOGGER - MESSAGE

See the LogFilePatternReceiver JavaDoc for more information (available from Chainsaw's help menu) and the example receiver configuration (available from the Welcome tab, the 'view example receiver configuration' button).

魂牵梦绕锁你心扉 2024-08-20 01:08:30

我在 Windows 上使用 Chainsaw v2 日志查看器

在“文件”菜单中,有一个选项“加载 Log4j 文件”,它允许您打开 Log4j XML 日志文件。

当然,您尝试打开的文件必须符合 log4j XML 架构。

I'm using Chainsaw v2 Log Viewer on Windows.

In the File menu there is an option 'Load Log4j file', which will allow you to open a Log4j XML log file.

Of course, the file you are trying to open must confirm to the log4j XML schema.

∞梦里开花 2024-08-20 01:08:30

是的,Chainsaw 可以读取常规文本日志文件 - 使用 LogFilePatternReceiver。请参阅“欢迎”选项卡中提供的示例配置。

Yes, Chainsaw can read regular text log files - use a LogFilePatternReceiver. See the example configuration available from the Welcome tab.

红尘作伴 2024-08-20 01:08:30

您的日志文件包含“优先级”和“类别”属性,而不是 Chainsaw 默认支持的“级别”、“记录器”。

您可以更改布局以生成关卡和关卡吗?类别属性?如果是这样,Chainsaw 应该能够处理您的日志文件。

如果您需要使用类别&优先级属性名称,我建议拉下 log4j 的 XmlDecoder 源并修改它以接受优先级和优先级属性名称。类别属性名称。然后,您可以将 Chainsaw 配置为使用 LogFileXMLReceiver 并指定您自己的 Decoder 实现。

Chainsaw 的“欢迎”选项卡提供了接收器配置示例。

这是 XMLDecoder 的来源:
https://github.com/apache/logging-chainsaw/blob/chainsaw-2.0.0-rc1/src/main/java/org/apache/log4j/xml/XMLDecoder.java

LogFileXMLReceiver 的 JavaDoc 应该可以从 Chainsaw 的帮助菜单中获得。

Your log file contains 'priority' and 'category' attributes instead of 'level', 'logger', which are supported by default in Chainsaw.

Can you change your layout to generate level & category attributes? If so, Chainsaw should be able to process your log file.

If you need to use category & priority attribute names, I'd suggest pulling down log4j's XmlDecoder source and modifying it to accept priority & category attribute names. You can then configure Chainsaw to use a LogFileXMLReceiver and specify your own Decoder implementation.

Chainsaw's Welcome tab provides an example receiver configuration.

Here's the source for XMLDecoder:
https://github.com/apache/logging-chainsaw/blob/chainsaw-2.0.0-rc1/src/main/java/org/apache/log4j/xml/XMLDecoder.java

The JavaDoc for LogFileXMLReceiver should be available from Chainsaw's help menu.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文