1

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?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
Rakesh Juyal
  • 35,919
  • 68
  • 173
  • 214

4 Answers4

2

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

Scott
  • 1,728
  • 11
  • 11
  • How about the log record looks like: <![CDATA[###Connection: Error reading object:Connection reset]]> <![CDATA[nodaltest,10.100.129.70,XXX]]> – PerlDev Jan 30 '10 at 15:24
1

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.

Cocowalla
  • 13,822
  • 6
  • 66
  • 112
  • @coco: i saw that option, but it is expecting an XML file. whereas i am having a .log file. – Rakesh Juyal Dec 03 '09 at 05:04
  • As mentioned in my answer, Chainsaw will only read log4j formatted XML files - so I'm afraid the answer to your question is 'no', Chainsaw cannot read your logs because they are not in the expected format – Cocowalla Dec 03 '09 at 07:51
1

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

Scott
  • 1,728
  • 11
  • 11
1

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.

Dwhitz
  • 1,250
  • 7
  • 26
  • 38
Scott
  • 1,728
  • 11
  • 11