我面对Spring Boot Logback的问题

时间:2018-11-30 11:39:14

标签: spring-boot

日志系统无法使用来自'classpath:logback-spring.xml'java.lang.IllegalStateException的配置进行初始化:检测到Logback配置错误:ch.qos.logback.core.pattern.parser.Compiler@3f102e87中存在ERROR在ch.qos.logback.core.pattern.parser.Compiler@3f102e87中没有为转换词[vtep1024] ERROR注册任何转换类-在ch.qos.logback.core.pattern.parser中,[vtep1024]不是有效的转换词ERROR .Compiler @ 27abe2cd-ch.qos.logback.core.pattern.parser.Compiler@27abe2cd中没有为转换字[vtep1024] ERROR注册任何转换类-在org.springframework.boot,[vtep1024]不是有效的转换字org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSpecificConfig(AbstractLoggingSystem.java:67)上的.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:166)


logback-string.xml文件

<property resource="application.properties" />

<springProperty scope="context" name="loggingFolder" source="logging.folder" defaultValue="logs" />
<springProperty scope="context" name="loggingFileName" source="logging.file.name" defaultValue="xxxx-xxxx-xxxx.log" />

<springProperty scope="context" name="loggingFileSizeMax" source="logging.file.size.max" defaultValue="10MB" />
<springProperty scope="context" name="loggingFileNameArchive" source="logging.file.name.archive" defaultValue="xxxx-xxxx-xxxx-%i.log.zip" />
<springProperty scope="context" name="loggingFileArchiveMaxFiles" source="logging.file.archive.maxFiles" defaultValue="10" />

<appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
    <!-- encoders are assigned the type
         ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->

    <encoder>
        <pattern>[${HOSTNAME}] [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] [%logger{36}] %msg%n</pattern>
    </encoder>
</appender>

<appender name="FILE_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${loggingFolder}/${loggingFileName}</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
        <fileNamePattern>${loggingFolder}/${loggingFileNameArchive}</fileNamePattern>
        <minIndex>1</minIndex>
        <maxIndex>${loggingFileArchiveMaxFiles}</maxIndex>
    </rollingPolicy>

    <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <maxFileSize>${loggingFileSizeMax}</maxFileSize>
    </triggeringPolicy>

    <append>true</append>
    <encoder>
        <pattern>[${HOSTNAME}] [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%-5level] [%logger{36}] %msg%n</pattern>
    </encoder>
</appender>

<root level="INFO">
    <appender-ref ref="FILE_APPENDER"/>
    <appender-ref ref="CONSOLE_APPENDER"/>
</root>

0 个答案:

没有答案
相关问题