springboot日志管理

1.使用logback记录日志

Springboot 已经默认帮你整合好了logback,日志输出文件在当前项目路径log文件夹下

(1)Maven依赖

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
</dependency>

(2)Logback配置

<configuration>
    
    
    
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d %p (%file:%line\)- %m%npattern>
            <charset>UTF-8charset>
        encoder>
    appender>

    
    
    
    
    <appender name="fileLog"
              class="ch.qos.logback.core.rolling.RollingFileAppender">
        <File>log/file/fileLog.logFile>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>log/file/fileLog.log.%d.%ifileNamePattern>
            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
                
                <maxFileSize>64 MBmaxFileSize>
            timeBasedFileNamingAndTriggeringPolicy>
        rollingPolicy>
        <encoder>
            <pattern>
                %d %p (%file:%line\)- %m%n
            pattern>
            <charset>UTF-8charset>
            
        encoder>
    appender>

    
    <appender name="sqlFile"
              

你可能感兴趣的:(SSM,spring,boot,java,log4j)