Details
-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
1.2.11
-
Windows 11:
Java 8
logback 1.2.11
slf4j 1.7.36
Description
java code with logback.xml failed withFailed java code with logback.xml failed with
22:01:51,235 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@14:22 - no applicable action for [root], current ElementPath is [[configuration][root]]
22:01:51,235 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@15:32 - no applicable action for [appender-ref], current ElementPath is [[configuration][root][appender-ref]]
If I move logback to classpath and java code run fine with
final Logger logger = LoggerFactory.getLogger(LogbackExample.class);
logger.info("Hello World");
java code:-----
final Logger logger = LoggerFactory.getLogger(LogbackExample.class);
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
lc.reset();
configurator.setContext(lc);
configurator.doConfigure("lib/logback.xml");
logger.info("Hello World");
logback.xml:-----
<configuration scan="true" scanPeriod="60 seconds" debug="true"><configuration scan="true" scanPeriod="60 seconds" debug="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d
[%thread] %-5level %logger
- %msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>