February 17, 2010

Viewing/Monitoring your Log4j Generated Log File with Chainsaw

Chainsaw is a open source tool for viewing and/or monitoring Log4j generating system. But the documentation on the homepage lack some explanation how to get started. To begin with maybe the simplest scenario, to view a log4j generated log file. The first thing one might misunderstand is that you need to defines a new configuration file for Chainsaw, so just pointing to your log4j.xm configuration file is not enough. Lets start with a example.

And the configuration file for Chainsaw.

Before we open Chainsaw lets write a small test program, that generates some log post, so we have something to view.

Now lets open Chainsaw. When first starting Chainsaw you are prompted to define a Receiver. Here we select our configuration file.

After selecting our Chainsaw configuration file, Chainsaw opens our log file in a new tab.

You might have already noticed the different formatting of logFormat attribute, compared with the Log4j and it is a question to me why they have done that. You can read more about the format in the LogFilePatternReceiver Javadoc.


Anonymous said...

Hi Magnus

Thought I'd let you know there have been lots of changes to Chainsaw, including support for building a Chainsaw receiver configuration from a log4j.xml or log4j.properties (at least, building logfilepatternreceivers from fileappender definitions).

If you'd like to try it, there's a developer snapshot available here:

Feel free to email me with questions or suggestions to my @apache.org account (sdeboy) or the log4j-dev mailing list.

Scott Deboy

Krzysztof said...

I have recently switched from Chainsaw to OtrosLogViewer (http://code.google.com/p/otroslogviewer). In my opinion is more intuitive and has ability to browse remote file systems. It's very useful when I have to open log using sftp. You have to only define log format.

Anonymous said...

Thanks for sharing