We have chosen log4j initially for simplicity and for being one of
the most popular loggers. I also think it's a good thing to give
developers who openid-enable their sites the option of using their
choice of loggers.
The questions then would be:
- which one should we use? commons-logging / slf4j / others?
- what's required to make the switch over to commons-logging
- can the configuration be kept simple?
- how will this change affect current deployments when they need to
upgrade?
Johnny
On 9-Sep-07, at 4:13 PM, Johan Karlberg wrote:
> libraries should depend
> on an abstract logging API, which in effect means slf4j-api or
> commons-logging, and leave the actuall logger to the implementing
> project.
We have chosen log4j initially for simplicity and for being one of
the most popular loggers. I also think it's a good thing to give
developers who openid-enable their sites the option of using their
choice of loggers.
The questions then would be:
- which one should we use? commons-logging / slf4j / others?
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId> <--------------Requires
</dependency><dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<optional>true</optional> <-----------------------optional
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.4</version>
</dependency>
- what's required to make the switch over to commons-logging
- can the configuration be kept simple?
- how will this change affect current deployments when they need to
upgrade?
Johnny
> I agree that commons-logging is the most used of the two. although
> I suspect
> that is mostly by virtue of having been around longer.
I'd say then that we should stay with commons-logging. If slf4j gains
popularity we can always switch over, with probably the same search/
replace effort as we're about to do now.
So, Sutra :) since you started this thread, would you like to do it?
Also: I'm still not clear if commons-logging picks up automatically
and enables a log4j.properties file from the classpath, or something
else needs to be configured as well. Does anyone have this answer
already?
The former would definitely be preferred, but we should document the
logging configuration regardless.
Thanks,
Johnny
In my experience, slf4j is a better choice for libraries because :
* it doesn't force users to follow the same backend logging as the lib
or to manage several configuration (simple, jdk, log4j, logback,...)
* the api is better than the one of commons-logging (it's not perfect,
but better)
if (logger.isDebugEnabled()) { logger.debug("toto ... "+ bar)}
become
logger.debug("toto {} ", bar);
* I lost time with the classloader issue, and conflict version of
commons-logging (when J2EE container already provide "out-dated"
version)
Several lib and framework have already switch to slf4j (jetty,
wicket... I don't know about spring or hibernate).
Just a fix about previous pom.xml sample :
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.4.2</version>
</dependency>
for a lib the dependency to slf4j-log4j12 must be remove, or set to
scope "test" or "provided" (like for servlet) because the final choice
is done by user.
my 2 cents (may be too later)