Logback 实现给变量指定默认值

格式是 ${变量名:-默认值},**光有冒号还不够,再加条短线后面才是默认值**

<appender name="info"  class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>/logs${log.folder:-/imeth}/info.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!-- daily rollover -->
            <fileNamePattern>/logs${log.folder:-/imeth}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
            <!-- keep 30 days worth of history -->
            <maxHistory>30</maxHistory>
            <maxFileSize>${log.file.size.max:-50}MB</maxFileSize>
        </rollingPolicy>
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
        <!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
        <encoder>
            <pattern>
                [%d{yyyy-MM-dd HH:mm:ss}] [%thread] [%-5level] %logger{35} -  %msg%n
            </pattern>
        </encoder>
    </appender>
收藏 (0)
评论列表
正在载入评论列表...
我是有底线的
为您推荐
    暂时没有数据