commons-logging

It always surprises me how many logging packages there are available for Java. There is the ubiquious Log4J, JDK1.4's logging API, the Avalon LogKit, IBM Alphaworks LoggingToolkit4J and I'm sure there are many more I've missed.

As a programmer, writing libraries this gets pretty difficult. You want to provide logging, but you also want your loggin to integrate into the applications logging system. The best way of doing this is to use a log wrapper like Jakarta Common's Logging. If you are like me, this is one of those wonderful little projects that you see the .jars for, but never have time to investigate. However, at work a while ago I needed to integrate Velocity into an application, and so I needed to figure out its logging.

Common-Logging really does make it very, very easy to get configurable logging for your application. It can be as simple as this:

	public class Blahh {
		private Log log = LogFactory.getLog(this.getClass());

		public someMethod() {
			log.debug( "Some method called" );
		}
	}

Even I (who admit to using System.out.println() on occassion) have to admit that is pretty damn nice.

Someday, I should investigate Monolog which does a similar job.

Leave a Reply

Your email address will not be published. Required fields are marked *