SLF4J日志配置,中文乱码解决


<configuration  scan="true" scanPeriod="60 seconds" debug="false">
    <contextName>logbackcontextName>
    <springProperty scope="context" name="logLevel" source="logging.levels"/>
    <springProperty scope="context" name="logPath" source="logging.path"/>
    
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%npattern>
            <charset>UTF-8charset>
        encoder>
    appender>

    
    <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>${logPath}logback.%d{yyyy-MM-dd}.logfileNamePattern>
        rollingPolicy>
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%npattern>
            <charset>UTF-8charset>
        encoder>
    appender>


    <root level="info">
        <appender-ref ref="console" />
        <appender-ref ref="file" />
    root>



configuration>

以上是配置文件,在spring boot的application.yaml中配置

#项目日志路径
logging:
  path: /usr/local/yuntu-service/yuntu-intelligent-log-system/log/
  levels: info

你可能感兴趣的:(spring)