<div dir="ltr"><div><div><div>Hello,<br><br></div>As stated in <a href="http://logback.qos.ch/setup.html">http://logback.qos.ch/setup.html</a> conditional processing in configuration files requires the Janino library. When running in an OSGi environment (e.g. an Eclipse RCP application) simply placing commons-compiler.jar and janino.jar on your application's class path is not sufficient enough. You will get the following exception:<br><br> <...><br>12:50:47,754 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG<br>12:50:47,755 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [stdout] to Logger[ROOT]<br>12:50:47,755 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [file] to Logger[ROOT]<br>12:50:47,810 |-ERROR in ch.qos.logback.core.joran.conditional.IfAction - Failed to parse condition [property("xxx.instance").equals("SIM_LOCAL")] org.codehaus.janino.JaninoRuntimeException: Cannot load class 'ch.qos.logback.core.joran.conditional.PropertyWrapperForScripts' through the parent loader<br>    at org.codehaus.janino.JaninoRuntimeException: Cannot load class 'ch.qos.logback.core.joran.conditional.PropertyWrapperForScripts' through the parent loader<br>    at     at org.codehaus.janino.SimpleCompiler$1.getDelegate(SimpleCompiler.java:306)<br>    at     at org.codehaus.janino.SimpleCompiler$1.accept(SimpleCompiler.java:291)<br>    at     at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:5159)<br>    at     at org.codehaus.janino.UnitCompiler.access$16700(UnitCompiler.java:185)<br>    at     at org.codehaus.janino.UnitCompiler$29.getSuperclass2(UnitCompiler.java:8154)<br>    at     at org.codehaus.janino.IClass.getSuperclass(IClass.java:406)<br>    at     at org.codehaus.janino.IClass.getIMethods(IClass.java:223)<br>    at     at org.codehaus.janino.IClass.getIMethods(IClass.java:199)<br>    at     at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:409)<br>    at     at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:393)<br>    at     at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:185)<br>    at     at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:347)<br>    at     at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1139)<br>    at     at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:354)<br>    at     at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:322)<br>    at     at org.codehaus.janino.SimpleCompiler.compileToClassLoader(SimpleCompiler.java:383)<br>    at     at org.codehaus.janino.ClassBodyEvaluator.compileToClass(ClassBodyEvaluator.java:315)<br>    at     at org.codehaus.janino.ClassBodyEvaluator.cook(ClassBodyEvaluator.java:233)<br>    at     at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:192)<br>    at     at org.codehaus.commons.compiler.Cookable.cook(Cookable.java:84)<br>    at     at org.codehaus.commons.compiler.Cookable.cook(Cookable.java:77)<br>    at     at ch.qos.logback.core.joran.conditional.PropertyEvalScriptBuilder.build(PropertyEvalScriptBuilder.java:51)<br>    at     at ch.qos.logback.core.joran.conditional.IfAction.begin(IfAction.java:67)<br>    at     at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:275)<br>    at     at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:147)<br>    at     at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:129)<br>    at     at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)<br>    at     at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149)<br>    at     at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135)<br>    at     at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99)<br>    at     at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:49)<br>    at     at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:77)<br>    at     at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:152)<br>    at     at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)<br>    at     at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)<br>    at     at org.slf4j.LoggerFactory.bind(LoggerFactory.java:141)<br>    at     at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:120)<br>    at     at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:331)<br>    at     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:283)<br>    at     at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:304)<br>    at     at com.xxx.yyy.client.ui.lifecycle.StartHandler.<init>(StartHandler.java:22)<br>    at     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)<br>    at     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)<br>    at     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)<br>    at     at java.lang.reflect.Constructor.newInstance(Constructor.java:422)<br>    at     at org.eclipse.e4.core.internal.di.ConstructorRequestor.execute(ConstructorRequestor.java:42)<br>    at     at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:343)<br>    at     at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:264)<br>    at     at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)<br>    at     at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:104)<br>    at     at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:73)<br>    at     at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:55)<br>    at     at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:235)<br>    at     at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:145)<br>    at     at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)<br>    at     at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)<br>    at     at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)<br>    at     at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)<br>    at     at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)<br>    at     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br>    at     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)<br>    at     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br>    at     at java.lang.reflect.Method.invoke(Method.java:497)<br>    at     at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)<br>    at     at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)<br>    at     at org.eclipse.equinox.launcher.Main.run(Main.java:1515)<br>    at     at org.eclipse.equinox.launcher.Main.main(Main.java:1488)<br>12:50:47,811 |-ERROR in ch.qos.logback.core.joran.conditional.IfAction - Failed to determine "if then else" result<br>12:50:47,811 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.<br><...><br><br></div>This exception occurs because in an OSGi environment the class loader of the org.cohehaus.janino bundle can not load classes from the ch.qos.logback.core bundle. See <a href="http://moi.vonos.net/java/osgi-classloaders/">http://moi.vonos.net/java/osgi-classloaders/</a> and <a href="http://nstouchstones.blogspot.co.at/2010/07/class-loader-architecture-comparison.html">http://nstouchstones.blogspot.co.at/2010/07/class-loader-architecture-comparison.html</a> for a primer on OSGi class loading.<br><br>The org.cohehaus.janino bundle would need a "Require-Bundle: ch.qos.logback.core" directive in it's manifest file in order for the bundle class loader to be able to load classes from the  ch.qos.logback.core bundle. This can be achieved by extending the org.cohehaus.janino bundle via a fragment (e.g. ch.qos.logback.core.janino.fragment). Below is the manifest of the fragment:<br><br>Manifest-Version: 1.0<br>Bundle-ManifestVersion: 2<br>Bundle-Name: Janino Fragment (needed to uses Janino together with logback in an OSGi environment)<br>Bundle-SymbolicName: ch.qos.logback.core.janino.fragment<br>Bundle-Version: 1.0.0<br>Fragment-Host: org.cohehaus.janino<br>Bundle-RequiredExecutionEnvironment: JavaSE-1.8<br>Require-Bundle: ch.qos.logback.core<br>Bundle-Vendor: Danube Development<br><br></div>I would like to ask if you would accept a pull request for <a href="https://github.com/qos-ch/logback-contrib">https://github.com/qos-ch/logback-contrib</a> or <a href="https://github.com/qos-ch/logback-extensions">https://github.com/qos-ch/logback-extensions</a> if I would prepare such a fragment (named e.g. ch.qos.logback.core.janino.fragment). <br><div><br></div><div>- Chris<br><br></div></div>