Robert Munteanu created FELIX-6248: -------------------------------------- Summary: Unable to use properties and conditions in logback.xml Key: FELIX-6248 URL: https://issues.apache.org/jira/browse/FELIX-6248 Project: Felix Issue Type: Bug Components: Felix Logback Reporter: Robert Munteanu Fix For: felix-logback-1.0.2
I am trying to consolidate multiple logback.xml into a single one using conditional processing and variables ( see http://logback.qos.ch/manual/configuration.html#definingProps ). I have updated the logback.xml {code:xml}<configuration debug="true"> <!-- default log level is INFO, can be overridden using -DLOGBACK_DEFAULT_LOG_LEVEL=... --> <variable name="$LOGBACK_DEFAULT_LOG_LEVEL" value="INFO" /> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>[%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <root level="${LOGBACK_DEFAULT_LOG_LEVEL}"> <appender-ref ref="STDOUT" /> </root> <!-- Silence excessive 'Best match for SASL auth was: SASL-PLAIN' messages --> <if condition='property("LOGBACK_DEFAULT_LOG_LEVEL").equalsIgnoreCase("INFO")'> <then> <logger name="org.apache.qpid.jms.sasl.SaslMechanismFinder" level="WARN"/> </then> </if> </configuration>{code} and then added two extra bundles to my application: - {{org.codehaus.janino/janino/3.1.2}} - {{org.codehaus.janino/commons-compiler/3.1.2}} When starting my application logback configuration fails with {noformat}16:44:57,642 |-ERROR in ch.qos.logback.core.joran.conditional.IfAction - Failed to parse condition [property("LOGBACK_DEFAULT_LOG_LEVEL").equalsIgnoreCase("INFO")] org.codehaus.commons.compiler.InternalCompilerExce ption: Compiling "SC" in Line 1, Column 1: Cannot load class 'ch.qos.logback.core.joran.conditional.PropertyWrapperForScripts' through the parent loader at org.codehaus.commons.compiler.InternalCompilerException: Compiling "SC" in Line 1, Column 1: Cannot load class 'ch.qos.logback.core.joran.conditional.PropertyWrapperForScripts' through the parent loader at at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:358) at at org.codehaus.janino.UnitCompiler.access$000(UnitCompiler.java:231) at at org.codehaus.janino.UnitCompiler$1.visitCompilationUnit(UnitCompiler.java:322) at at org.codehaus.janino.UnitCompiler$1.visitCompilationUnit(UnitCompiler.java:319) at at org.codehaus.janino.Java$CompilationUnit.accept(Java.java:367) at at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:319) at at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:237) at at org.codehaus.janino.ClassBodyEvaluator.cook(ClassBodyEvaluator.java:278) at at org.codehaus.janino.ClassBodyEvaluator.cook(ClassBodyEvaluator.java:272) at at org.codehaus.janino.ClassBodyEvaluator.cook(ClassBodyEvaluator.java:252) at at org.codehaus.commons.compiler.Cookable.cook(Cookable.java:82) at at org.codehaus.commons.compiler.Cookable.cook(Cookable.java:77) at at ch.qos.logback.core.joran.conditional.PropertyEvalScriptBuilder.build(PropertyEvalScriptBuilder.java:47) at at ch.qos.logback.core.joran.conditional.IfAction.begin(IfAction.java:65) at at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:269) at at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:145) at at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:128) at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:165) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:152) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:110) at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53) at at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75) at at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150) at at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84) at at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55) at at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) at at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124) at at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357) at at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383) at at org.apache.felix.configadmin.plugin.interpolation.Activator.<clinit>(Activator.java:40) at at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at at java.base/java.lang.Class.newInstance(Class.java:584) at at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:4750) at at org.apache.felix.framework.Felix.activateBundle(Felix.java:2383) at at org.apache.felix.framework.Felix.startBundle(Felix.java:2308) at at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1539) at at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308) at at java.base/java.lang.Thread.run(Thread.java:834) Caused by: org.codehaus.commons.compiler.InternalCompilerException: Cannot load class 'ch.qos.logback.core.joran.conditional.PropertyWrapperForScripts' through the parent loader at at org.codehaus.janino.SimpleCompiler$2.getDelegate(SimpleCompiler.java:389) at at org.codehaus.janino.SimpleCompiler$2.accept(SimpleCompiler.java:362) at at org.codehaus.janino.UnitCompiler.getType(UnitCompiler.java:6395) at at org.codehaus.janino.UnitCompiler.access$1300(UnitCompiler.java:231) at at org.codehaus.janino.UnitCompiler$33.getSuperclass2(UnitCompiler.java:9935) at at org.codehaus.janino.IClass.getSuperclass(IClass.java:456) at at org.codehaus.janino.IClass.getIMethods(IClass.java:261) at at org.codehaus.janino.IClass.getIMethods(IClass.java:238) at at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:461) at at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:401) at at org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:231) at at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:380) at at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:375) at at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1692) at at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:375) at at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:348) at ... 42 common frames omitted{noformat} -- This message was sent by Atlassian Jira (v8.3.4#803005)