5
votes

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?

3

3 Answers

3
votes

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.

3
votes

I had the same issue and I added log4j.properties to my /src folder.

2
votes

UPDATE: This doesn't really help with your issue...

I am just researching OSGi myself.

Not quite what you're looking for, but the following post discusses the same issue when using vanilla equinox (ie: not hosted within tomcat/jetty).

It suggests creating a 'fragment bundle' (example available for download) to hold your log4j.properties. Perhaps you could try something similar?

Or perhaps you just need to place the log4j.properties inside META-INF of your WAR?