How can I use logging in OSGi?
OSGi platforms do not change the way libraries work, it just enforces tighter classloading. Thus, you can, in most of the cases, use the same logging strategy used in non-OSGi environments. Spring (and Spring DM) use internally the commons-logging API which acts as an “ultra-thin bridge between different logging implementations”. In OSGi, just like in a non-OSGi environment, Spring and Spring DM delegate all logging (including initialisation) to the actual commons-logging API implementation. Out of the box, SLF4J library is provided, which shares the same purpose as commons-logging but without the class loading discovery mechanism (that causes loading issues), using static wiring (see the SLF4J site for more info). To use slf4j, make sure you use: slf4j-api-XXX.jar, jcl104-overslf4j-XXX.jar and slf4j-log4j-XXX.jar (where XXX stands for the slf4j version). The last jar provides the static wiring between slf4j and log4j – if another implementation is desired (such as jdk14), then a diffe