<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi everyone,<div><br></div><div>I am migrating an OSGi-based application from System.out.println to slf4j / logback and I am having some problems.</div><div><br></div><div>I have provided logback with a configuration file via the "logback.configurationFile" and it works very well.</div><div><br></div><div>In this configuration file, I have defined a specific appender that I have developed, but logback fails to instantiate it (cf. stacktrace below).</div><div><br></div><div>This is not really a surprise: each OSGi bundle has its own classloader. My org.test.LogConsole is in its own bundle and thus logback classloader cannot find it.</div><div><br></div><div>One solution is to declare my org.test.LogConsole bundle as a fragment of logback. The fragment bundle is not a bundle per se and shares its classloader with the host bundle.</div><div><br></div><div>This is however very constraining in term of bundle resolution / starting order as the fragment bundle has to be installed before the host.</div><div><br></div><div>Isn't there another way (such as LogBack.Configuration.addClassloader()) to indicate logback classic where to search for my org.test.LogConsole class ?</div><div><br></div><div>Kind regards,</div><div><br></div><div>Ben</div><div><br></div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; ">10:58:48,848 |-ERROR in ch.qos.logback.core.joran.action.AppenderAction - Could not create an Appender of type [org.test.LogConsole]. <span style="text-decoration: underline ; color: #001993">ch.qos.logback.core.util.DynamicClassLoadingException</span>: Failed to instantiate type org.test.LogConsole</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span style="text-decoration: underline ; color: #001993">ch.qos.logback.core.util.DynamicClassLoadingException</span>: Failed to instantiate type org.test.LogConsole</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.core.util.OptionHelper.instantiateByClassNameAndParameter(<span style="text-decoration: underline ; color: #001993">OptionHelper.java:74</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(<span style="text-decoration: underline ; color: #001993">OptionHelper.java:49</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.core.util.OptionHelper.instantiateByClassName(<span style="text-decoration: underline ; color: #001993">OptionHelper.java:35</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.core.joran.action.AppenderAction.begin(<span style="text-decoration: underline ; color: #001993">AppenderAction.java:54</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(<span style="text-decoration: underline ; color: #001993">Interpreter.java:276</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.core.joran.spi.Interpreter.startElement(<span style="text-decoration: underline ; color: #001993">Interpreter.java:148</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.core.joran.spi.Interpreter.startElement(<span style="text-decoration: underline ; color: #001993">Interpreter.java:130</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.core.joran.spi.EventPlayer.play(<span style="text-decoration: underline ; color: #001993">EventPlayer.java:50</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(<span style="text-decoration: underline ; color: #001993">GenericConfigurator.java:157</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(<span style="text-decoration: underline ; color: #001993">GenericConfigurator.java:143</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(<span style="text-decoration: underline ; color: #001993">GenericConfigurator.java:106</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(<span style="text-decoration: underline ; color: #001993">GenericConfigurator.java:56</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.classic.util.ContextInitializer.configureByResource(<span style="text-decoration: underline ; color: #001993">ContextInitializer.java:75</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at ch.qos.logback.classic.util.ContextInitializer.autoConfig(<span style="text-decoration: underline ; color: #001993">ContextInitializer.java:148</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at org.slf4j.impl.StaticLoggerBinder.init(<span style="text-decoration: underline ; color: #001993">StaticLoggerBinder.java:84</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at org.slf4j.impl.StaticLoggerBinder.<clinit>(<span style="text-decoration: underline ; color: #001993">StaticLoggerBinder.java:54</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at org.slf4j.LoggerFactory.bind(<span style="text-decoration: underline ; color: #001993">LoggerFactory.java:128</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at org.slf4j.LoggerFactory.performInitialization(<span style="text-decoration: underline ; color: #001993">LoggerFactory.java:107</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at org.slf4j.LoggerFactory.getILoggerFactory(<span style="text-decoration: underline ; color: #001993">LoggerFactory.java:295</span>)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre"> </span>at <span class="Apple-tab-span" style="white-space:pre"> </span>at org.slf4j.LoggerFactory.getLogger(<span style="text-decoration: underline ; color: #001993">LoggerFactory.java:269</span>)</div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px"><span class="Apple-tab-span" style="white-space:pre"> </span><br class="webkit-block-placeholder"></p></div></body></html>