Monday, November 5, 2007

commons logging and log4j

Few weeks before there was a mail discussion on getting rid of commons-logging from ws projects and the answers from people were all +1 . I wanted to have a look but I couldn't manage better time to look it.

Yesterday my friend Thayapavan was asking a related question on what's the different between log4j and commons-logging. Interestingly it was asked by a an interviewer which is clear now that people start thinking on why we use these two jars just because they are there !

First question is why we need commons logging? The idea of commons logging must have come from the concept that logging implementation is an integration feature, not a development feature. Developers use commons logging in their code without worrying of what the implementation is. It is the integration people to decide whether to use log4j, or jdk logger or any other proprietary ones.

So I think it is a development choice. You would not like to tie log4j in to your source in case you want to change it in future (example jdk one) . But I think 8 out of 10 times people wouldn't do it. And people who have tasted writing the Appenders and the other fancies what log4j has (specially after log4j 1.2) wouldn't even think of it ! So if you are comfortable using it then go for it instead wrap it with commons-logging. Or want be too smart and depend on integrators to decide then go for commons-logging !

No comments: