Thursday, December 08, 2005

Taming Log4J

Note: My posts are coming a little slower recently due to impending deadlines and holiday chores. I still plan on posting as much useful content as possible, but I expect the slower than usual pace will last for the next few weeks.

A co-worker and myself were working late, trying to solve one last problem before playing some foosball and calling it a night. We were not only baffled by the problem, but also by our inability to get Log4J to print out debugging information. We changed the properties file, and restarted the app server via a script that we have permission to run but not edit, but the app server wasn't seeing the changes. Unfortunately we had very limited access regarding the app server, which apparently wasn't behaving properly, and the hour was late, so trying to find an admin with access would be difficult. I did though have the ability to install a web application, in a round-about way, and another co-worker had found a web application that allowed for the configuration of Log4J without a server restart. This is when I installed LogWeb.

On the LogWeb struts application created by codeczar that allows you to configure Log4J through a web application. It features view all of the configured loggers, add additional loggers, set their log levels, list appenders, add and configure appenders, and pretty much everything else you can do in the Log4J configuration file.

There is the ability to download the in memory Log4J configuration as a log file. To compliment this feature is tool which allows you to upload a configuration file. For me, this feature alone has a high cool factor. You could create several Log4J configuration files for debugging issues, or perhaps just to spy on things to make sure that everything is running as you expected. You could then use LogWeb to load the Log4J properties file that best matched the information that you wanted to extract. For example, maybe you want to capture the database activity on your production server for a period of ten minutes, just long enough to get a solid dataset to browse through. With LogWeb you could upload the new properties file, then in ten minutes reload the original, all without restarting or reconfiguring the server.

If you rely with Log4J, Ii strongly recommend taking this tool for a test drive. It worked out of the box, just deploy the war file and use. Of course, you should probably configure your server to hide the tool from public view. But maybe you don't have the ten minutes (I know the feeling), you can go to the LogWeb website and take LogWeb for a test drive with slightly reduced functionality.

Next I need to find myself a good JMX web-based tool...

No comments: