其他分享
首页 > 其他分享> > SpringBoot项目添加EurekaClient日志出问题

SpringBoot项目添加EurekaClient日志出问题

作者:互联网

问题症状

日志里同时出现正常的日志目录和 IS_UNDEFINED

 

 application.properties如下

logging.file.path=logs
spring.application.name=mes

logback-spring.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
    <contextName>MES</contextName>
     
    <springProperty scope="context" name="logLevel" source="logging.level.root"/>
       
    <springProperty scope="context" name="logPath" source="logging.file.path"/>
       
    <springProperty scope="context" name="applicationName" source="spring.application.name"/>

    <!-- 彩色日志格式 -->
    <property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-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="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>${logLevel}</level>
        </filter>
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern>
            <!--<pattern>${CONSOLE_LOG_PATTERN}</pattern>-->
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
    </appender>

    <!--输出到文件-->
    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>${logPath}/${applicationName}.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            <!-- daily rollover -->
            <fileNamePattern>${logPath}/${applicationName}/${applicationName}.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
            <!-- keep 30 days' worth of history capped at 3GB total size -->
            <maxHistory>90</maxHistory>
            <maxFileSize>50MB</maxFileSize>
            <totalSizeCap>30GB</totalSizeCap>
        </rollingPolicy>
        <encoder  class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern>
            <charset>utf-8</charset>
        </encoder>
    </appender>

    <!--<logger name="io.netty.handler.codec.http.websocketx" level="ERROR"/>-->
    <!--<logger name="io.lettuce.core.protocol" level="ERROR"/>-->
    <!--<logger name="io.lettuce.core" level="ERROR"/>-->
    <!--<logger name="org.apache.http.headers" level="ERROR"/>-->
    <!--<logger name="org.apache.http.wire" level="ERROR"/>-->
    <!--<logger name="io.netty.handler.logging" level="ERROR"/>-->
    <logger name="org.springfromework" level="${logLevel}"/>
    <logger name="org.springframework.boot.autoconfigure" level="ERROR"/>
    <root level="${logLevel}">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="FILE"/>
    </root>
</configuration>

 

原因:springcloud优先加载bootstrap.properties/bootstrap.yml

新建一个配置文件bootstrap.properties/bootstrap.yml将配置属性,放置进去

logging.file.path=logs
spring.application.name=mes

参考来源:【Springboot】使用logback莫名出现 IS_UNDEFINED 日志目录,其中记录的是 bootstrap.info.log 相关日志

标签:SpringBoot,EurekaClient,spring,bootstrap,yyyy,--,日志,log
来源: https://www.cnblogs.com/passedbylove/p/14189190.html