Spring Boot - logback PARSER_ERROR

2019-01-09 19:37发布

问题:

I am using Spring Boot 1.2.0 and the below logback.xml file but for some reason, I see log lines that start like this. What is this PARSER_ERROR[wex]? Any idea? Completely removing logback.xml makes the PARSER_ERROR[wex] go away but the lig file has the literal "${PID:- }" logged instead of the PID

%PARSER_ERROR[wex]2014-12-30 12:25:25.730  INFO 77114 [localhost-startStop-1]

logback.xml

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


    <property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/>
    <property name="FILE_LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${PID:- } [%t] --- %-40.40logger{39} : %m%n%wex"/>

    <appender name="FILE"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <encoder>
            <pattern>${FILE_LOG_PATTERN}</pattern>
        </encoder>
        <file>${LOG_FILE}</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <fileNamePattern>${LOG_FILE}.%i</fileNamePattern>
        </rollingPolicy>
        <triggeringPolicy
                class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <MaxFileSize>10MB</MaxFileSize>
        </triggeringPolicy>
    </appender>

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

</configuration>

Digging into the source, I see wex as a conversionRule over here but I am not sure what it is doing or how a PARSER_ERROR is happening. I am trying to dig deeper but if I am doing something obviously wrong, please let me know.


Update 1:

Adding the line

<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />

in the logback.xml file seems to have fixed it. The strange thing is, I have to explicitly add the conversionRule even if I include the defaults.xml explicitly. Why?