用于登录的XML配置问题

问题描述 投票:0回答:1

我正在尝试通过LogstashTcpSocketAppender配置logback-spring.xml。当我将行<stackTrace>添加到LogstashEncoder时,出现错误Error is: "weblogic.application.ModuleException: java.lang.IllegalStateException: Logback configuration error detected: ERROR in ch.qos.logback.core.joran.spi.Interpreter@51:25 - no applicable action for [stackTrace], current ElementPath is [[configuration][appender][encoder][stackTrace]]。如果我删除<stackTrace><fieldName>stackTrace</fieldName>而仅保留<throwableConverter>,则效果很好。任何帮助深表感谢。

logback-spring.xml

<appender name="LOGSTASH"
              class="net.logstash.logback.appender.LogstashTcpSocketAppender">
        <destination>${LOGSTASH_HOST}:${LOGSTASH_PORT}</destination>
        <encoder charset="UTF-8"
                 class="net.logstash.logback.encoder.LogstashEncoder">
            <stackTrace>
                <fieldName>stackTrace</fieldName>
                <throwableConverter
                        class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
                    <rootCauseFirst>true</rootCauseFirst>
                </throwableConverter>
            </stackTrace>
        </encoder>
    </appender>

    <appender name="ASYNC_LOGSTASH"
              class="ch.qos.logback.classic.AsyncAppender">
        <appender-ref ref="LOGSTASH"/>
    </appender>

错误日志:

Caused By: java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter@51:25 - no applicable action for [stackTrace], current ElementPath  is [[configuration][appender][encoder][stackTrace]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@52:28 - no applicable action for [fieldName], current ElementPath  is [[configuration][appender][encoder][stackTrace][fieldName]]
        at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:166)
        at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:82)
        at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
        at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:114)
        at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:264)
        Truncated. see log file for complete stacktrace
java logback spring-logback logstash-logback-encoder
1个回答
0
投票

我相信<stackTrace>必须位于编码器的<providers>元素中。

© www.soinside.com 2019 - 2024. All rights reserved.