SpringBoot 3.1.4 generated .log directory is undefined. How to fix it?

89 views Asked by At

This is my logback-spring.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration  scan="true" scanPeriod="10 seconds">
    <contextName>logback</contextName>

    <springProperty scope="context" name="logLocation" source="logging.file.path" default="/data/applog/zzq/init"/>

    <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
    <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
    <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
    <!-- Colorful -->
    <property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>


    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${CONSOLE_LOG_PATTERN}</pattern>
        </encoder>
    </appender>

    <appender name="logFile"  class="ch.qos.logback.core.rolling.RollingFileAppender">
        <Prudent>true</Prudent>
        <encoder>
            <pattern>%d{MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
            <charset>UTF-8</charset>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <FileNamePattern>
                ${logLocation}/%d{yyyy-MM-dd}/%d{MM-dd}.%i.log
            </FileNamePattern>
            <maxFileSize>500MB</maxFileSize>
            <maxHistory>180</maxHistory>
        </rollingPolicy>
    </appender>

    <root level="debug">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="FILE"/>
    </root>

    <root level="info">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="FILE"/>
    </root>

    <root level="error">
        <appender-ref ref="console"/>
        <appender-ref ref="logFile" />
    </root>

</configuration>

This is my application.yml:

logging:
  config: classpath:logback-spring.xml
  file:
    path: /data/applog/zzq/${spring.application.name}
  level:
    com.xmzn: debug
    com.baomidou.mybatisplus: debug
    com.*.mapper: debug
    org.springframework: info

It works fine on windows, storing directly to the specified directory, but running it on linux (CentOS7) generates the directory logLocation_IS_UNDEFINED

Windows

linux

How can I fix it? Are there some other methods?

0

There are 0 answers