How to configure Log4J when deploying an OSGi app with the Equinox Servle Bridge to Tomcat?

arturh picture arturh · Apr 1, 2009 · Viewed 7.2k times · Source

When deploying my OSGi web application using the equinox servlet bridge i get the following:

log4j:WARN No appenders could be found for logger (org.springframework.osgi.extender.internal.activator.ContextLoaderListener).
log4j:WARN Please initialize the log4j system properly.

I tried several ways of supplying the necessary "log4j.properties" file, including:

  • adding the context-param "log4jConfigLocation" to the servlet bridge web.xml
  • creating a folder "classes" in the WEB-INF folder and copying my log4j.properties file there (and copying it in several other locations)
  • removing my log4j bundle and setting "extendedFrameworkExports" to org.apache.log4j so (I guess) the tomcat log4j is used ... this did not work because my dependencies need some slf4j classes which are provided as a fragment for the log4j bundle ... which isn't there anymore ...

Of course I also have a fragment bundle which extends the log4j bundle with a log4j.properties file, but it looks like this log4j bundle is not used.

ADDED: I should add that I'm developing the application in Eclipse... and my fragment bundle which configures log4j / slf4j works there.

Has anyone solved this? Any ideas?

Answer

arturh picture arturh · Apr 2, 2009

I found my error. The fragment which should provide the log4j.properties file did not include it, because I did not add it to the binary build in build.properties.