gpt4 book ai didi

java - Spring-Boot中的LOG配置

转载 作者:行者123 更新时间:2023-12-02 01:05:29 25 4
gpt4 key购买 nike

我已按如下方式配置了 logback.xml,但在运行时出现错误,请任何人帮我解决。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="LOG_DIR" value="D:\\FlightReserVAtionProject\\LOG">

<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_DIR}\\${FILE_PREFIX}.log</file>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>$%d{yyyy-MM-dd HH:mm:ss} - %msg%n</pattern>
</encoder>

<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_DIR}\\archived\\${FILE_PREFIX}.$%d{yyyy-MM-dd
HH:mm:ss}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"></timeBasedFileNamingAndTriggeringPolicy>
<maxFileSize>2MB</maxFileSize>
</rollingPolicy>

</appender>
</configuration>

错误是

java.lang.IllegalStateException: Logback configuration error detected: ERROR in ch.qos.logback.core.joran.spi.Interpreter@18:17 - no applicable action for[maxFileSize], current ElementPath  is [[configuration][appender[rollingPolicy][maxFileSize]]ERROR in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@20f5281c - maxFileSize property is mandatory.

最佳答案

按如下方式更改您的配置。 maxFileSize 是标签 timeBasedFileNamingAndTriggeringPolicy 的子属性。

<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>2MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>

关于java - Spring-Boot中的LOG配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57735912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com