回溯文件错误:[配置]没有适用的操作,当前的ElementPath是[[configuration] [configuration]]

时间:2016-02-24 16:03:33

标签: logging logback

我正在尝试配置如下所示的logback,但它会抛出这个错误。配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>

<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
    <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
    <encoder>
        <pattern>%d{ISO8601} %-5p [%c] %msg%n</pattern>
    </encoder>
</appender>

<appender name="mediator" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
    <file>logs/mediator/cbs_mediator_rapid.log</file>
    <append>true</append>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>logs/mediator/cbs_mediator_rapid_%d{yyyyMMdd}_%d{HHmmss,aux}_%i.log</fileNamePattern>
        <TimeBasedFileNamingAndTriggeringPolicy class="com.bosch.cbs.util.log.StartupSizeAndTimeBasedFNATP">
            <maxFileSize>250MB</maxFileSize>
        </TimeBasedFileNamingAndTriggeringPolicy>
        <maxHistory>30</maxHistory>
    </rollingPolicy>
    <encoder>
        <charset>utf-8</charset>
        <pattern>%d{ISO8601} %-5p [%c] %msg%n</pattern>
    </encoder>
</appender>

<appender name="activemq" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
    <file>logs/activemq/cbs_mediator_rapid_activemq.log</file>
    <append>true</append>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>logs/activemq/cbs_mediator_rapid_activemq_%d{yyyyMMdd}_%d{HHmmss,aux}_%i.log</fileNamePattern>
        <TimeBasedFileNamingAndTriggeringPolicy class="com.bosch.cbs.util.log.StartupSizeAndTimeBasedFNATP">
            <maxFileSize>250MB</maxFileSize>
        </TimeBasedFileNamingAndTriggeringPolicy>
        <maxHistory>30</maxHistory>
    </rollingPolicy>
    <encoder>
        <charset>utf-8</charset>
        <pattern>%d{ISO8601} %-5p [%c] %msg%n</pattern>
    </encoder>
</appender>

<logger name="com.bosch.cbs.mediator" level="INFO" additivity="false">
    <appender-ref ref="mediator" />
</logger>

<logger name="org.apache.activemq" level="INFO" additivity="false">
    <appender-ref ref="activemq" />
</logger>

<logger name="org.apache.activemq.spring" level="WARN" additivity="false">
    <appender-ref ref="activemq" />
</logger>

<root level="INFO">
    <appender-ref ref="mediator" />
</root>

------所以------

我收到以下错误。

16:56:48,212 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@2:42 - no applicable action for [configuration], current ElementPath  is [[configuration][configuration]]
16:56:48,212 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@4:74 - no applicable action for [appender], current ElementPath  is [[configuration][configuration][appender]]
16:56:48,213 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@6:18 - no applicable action for [encoder], current ElementPath  is [[configuration][configuration][appender][encoder]]
16:56:48,213 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@7:22 - no applicable action for [pattern], current ElementPath  is [[configuration][configuration][appender][encoder][pattern]]

我已经浏览了stackoverflow并纠正了一些错误。但它仍然无效。请帮忙!!

1 个答案:

答案 0 :(得分:2)

如果你使用弹簧靴,那么你必须使用。单独定义您的logback并包含它们。有关此问题,请参阅details。 的的logback-spring.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProfile name="staging, production">
    <include resource="logback-production.xml"/>
</springProfile>

<springProfile name="dev">
        <include resource="logback-dev.xml"/>
</springProfile>

</configuration>

https://github.com/spring-projects/spring-boot/issues/3503