[slf4j-user] SLF4J and JBoss classloaders

Paul Oswald pauloswald at gmail.com
Mon Aug 27 17:51:20 CEST 2007


I'm going to give some background information here but skip to the end
if to see my slf4j specific question...

I've just recently switched a large J2SE/J2EE application over to the
slf4j API. I've also been using the log4j backend so far (previously
it was jdk logging). When the code is running out of container, I pass
a command line parameter into the applciation to specify the location
of log4j.properties and the log file location. That works great.

When deployed inside JBoss 4.0.4.GA or 4.2.1.GA however, The logging
message seems to come out twice. A normal server log in JBoss looks
like this:

16:41:57,793 INFO  [TomcatDeployer] deploy, ctxPath=/,
warUrl=.../deploy/jbossweb-tomcat55.sar/ROOT.war/

However a line from my application looks like this:

11:23:46,806 INFO  [STDOUT] 11:23:46,806 WARN
[ActionDAO$ActionDAOImpl] This is the message

Note the source is STDOUT, there are two dates and the catagories are
different. The log4j pattern string for JBoss is: %d{ABSOLUTE} %-5p
[%c{1}] %m%n You can see that the first three things are coming out
ok, however when coming from my app, the message also contains a date,
catagory and caller information. Modifying JBoss' log4j configuration
only changes the first three. I've found some log4j.property files
packed inside of jars we are including into our ear file and removed
them and that changed how the second part was formatted. It's still
really weird that the category on some lines are both WARN and INFO
though.

So this brings me to my actual question: what is the official
recommendation for using slf4j with JBoss? They do some interesting
classloading things to isolate jars from each other so I've gotten
myself throughouly confused. Currently, I'm packing the slf4j api and
slf4j-log4j backend into my ear file. I am excluding log4j.jar because
that should be provided by the server. Why does it seemingly go
through log4j processing twice?  I suppose I'm supposed to include my
own log4j.properties file in the ear as well? My understanding was
that applications should leave the logging decisions up to the
container and therefore not include a config file, but nothing I do to
log4j.xml in jboss will make the DEBUG level come out.

Thanks!
-Paul



More information about the slf4j-user mailing list