开发者

Is it possible to read the log file using 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 ques开发者_如何转开发tion is, Is it possible to read the log file using Chainsaw?


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.


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).


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜