logback配置文件动态加载问题
logback配置文件手动加载的时候,第一次没有问题,第二次就会出现问题,求各路大神指点:加载代码为:
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
lc.reset();
configurator.setContext(lc);
configurator.doConfigure("F:\\logback.xml");
logback.xml里出现错误的配置为:
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator>
<expression>message.contains("imsi")</expression>
</evaluator>
<OnMismatch>DENY</OnMismatch>
<OnMatch>ACCEPT</OnMatch>
</filter>
控制台报的错误为:
02:12:21,859 |-ERROR in ch.qos.logback.classic.boolex.JaninoEventEvaluator@5d68fa45 - Could not start evaluator with expression [message.contains("imsi")] org.codehaus.commons.compiler.CompileException: Line 1, Column 7: A class 'ch.qos.logback.classic.Level' could not be found
at org.codehaus.commons.compiler.CompileException: Line 1, Column 7: A class 'ch.qos.logback.classic.Level' could not be found
at at org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:9779)
at at org.codehaus.janino.UnitCompiler.getSingleTypeImport(UnitCompiler.java:8299)
at at org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:338)
at at org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:320)
at at org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1017)
at at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:327)
at at org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:293)
at at org.codehaus.janino.SimpleCompiler.compileToClassLoader(SimpleCompiler.java:310)
at at org.codehaus.janino.ClassBodyEvaluator.compileToClass(ClassBodyEvaluator.java:319)
at at org.codehaus.janino.ScriptEvaluator.cook(ScriptEvaluator.java:563)
at at org.codehaus.janino.ScriptEvaluator.cook(ScriptEvaluator.java:462)
at at org.codehaus.janino.ScriptEvaluator.cook(ScriptEvaluator.java:374)
at at org.codehaus.janino.SimpleCompiler.cook(SimpleCompiler.java:178)
at at org.codehaus.commons.compiler.Cookable.cook(Cookable.java:80)
at at org.codehaus.commons.compiler.Cookable.cook(Cookable.java:73)
at at org.codehaus.janino.ScriptEvaluator.<init>(ScriptEvaluator.java:147)
at at ch.qos.logback.core.boolex.JaninoEventEvaluatorBase.start(JaninoEventEvaluatorBase.java:57)
at at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.end(NestedComplexPropertyIA.java:167)
at at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317)
at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196)
at at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182)
at at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:76)
at at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:68)
at at com.log.loader.LogbackConfigLoader.load(LogbackConfigLoader.java:43)
at at com.log.servlet.OnloadStart.signalCallback(OnloadStart.java:51)
at at com.log.servlet.OnloadStart.handle(OnloadStart.java:45)
at at sun.misc.Signal$1.run(Signal.java:212)
at at java.lang.Thread.run(Thread.java:724) logback
补充:Java , Java相关