SpringBoot项目添加EurekaClient日志出问题

2021-03-09 02:28

阅读:710

标签:back   deb   dai   问题   boot   coder   classic   rgb   blog   

问题症状

日志里同时出现正常的日志目录和 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>MEScontextName>
     
    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%npattern>
            
            charset class="java.nio.charset.Charset">UTF-8charset>
        encoder>
    appender>

    
    appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
        file>${logPath}/${applicationName}.logfile>
        rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
            
            fileNamePattern>${logPath}/${applicationName}/${applicationName}.%d{yyyy-MM-dd}.%i.logfileNamePattern>
            
            maxHistory>90maxHistory>
            maxFileSize>50MBmaxFileSize>
            totalSizeCap>30GBtotalSizeCap>
        rollingPolicy>
        encoder  class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%npattern>
            charset>utf-8charset>
        encoder>
    appender>

    
    
    
    
    
    
    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日志出问题

标签:back   deb   dai   问题   boot   coder   classic   rgb   blog   

原文地址:https://www.cnblogs.com/passedbylove/p/14189190.html


评论


亲,登录后才可以留言!