[slf4j-user] SLF4J and JBoss classloaders

Paul Oswald pauloswald at gmail.com
Thu Aug 30 17:50:24 CEST 2007

Jacob and Ceki, Thanks for the responses:

Have you read the Jboss' documentation on logging [1]?

Yes I have. The sections 10.3.6 - 10.3.8 seem to be about specifying your
own configuration file in the ear/war that log just your application's
messages. The following seems like a good resource for that too but at this
point I was taking the advice of not worrying about this as I am only
running one ear per server. (http://www.qos.ch/logging/sc.jsp)  I was trying
to do something more like what is outlined in 10.3.1 of the JBoss wiki page
where I modify the server's log4j config and add my config in there.

In particular, are you doing anything special to modify JBoss' classloading
> behavior?

No. I'm using a standard JBoss 4.0.4.GA install.

Jacob Replied:
> When you log to the console logger, it's logging stuff from one logger
> repository over the logging configuration
> of another logger repository; hence both the "INFO" and "WARN" entries in
> one logging statement.

That makes sense.

Now, as far as your logging configuration, have you tried to configure
> manaully or are you counting on automatic configuration occurring?  For
> logger
> repositories other than the default, automatic configuration will not
> occur.

I was assuming that by not having a log4j config file or a log4j.jar in my
ear, I could add my configurations to the server log4j file and have it
ouput there but it doesn't seem to work the way I expected. Since I couldn't
make that work I'm now trying to do it the other way and adding a
log4j.xmlfile to the war WEB-INF and the jar to the lib directory.
What I don't know
is how the slf4j stuff fits into this equation... do I need the backend
selector jar packed into each war/ear so that the scoped classloader can
route correctly? Here is what I am trying to configure now:

Server code --> Log4J API --> (Jboss Log4j + server/conf/log4j.xml) -->

App code (war) --> slf4j-log4j.jar --> slf4j-log4j.jar -->
(war/WEB-INF/log4j.jar + war/WEB-INF/log4j.xml) --> application.log

App code (some libs) --> jcl104-over-slf4j.jar --> (war/WEB-INF/log4j.jar +
war/WEB-INF/log4j.xml) --> application.log

App code (some libs) --> Log4j API directly --> (war/WEB-INF/log4j.jar +
war/WEB-INF/log4j.xml) --> application.log

So overall, there are 4 possible routes. Does this make sense with what
JBoss does? I'm finding it really quite frustrating to configure because a
log4j.properties file in any jar included in your project from a 3rd party
lib affects what comes out to the server.log. I really want log4j to ignore
everything in the ear/war/jars and just use the container's configuration.
There is no reason logging configuration decisions should be made when you
package your application.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/slf4j-user/attachments/20070830/eb7a6682/attachment.htm>

More information about the slf4j-user mailing list