In a previous study
Notes by drawing red line, you can log in below log.debug output directly to the console, but in the debug log file written not so smooth, looking for N configurations, the following method is feasible
First, make sure that has been introduced lombok and plug-ins
1, the configuration file in the directory Resource follows logback-spring.xml
<? XML Version = "1.0" encoding = "UTF-. 8" ?> < Configuration Scan = "to true" scanPeriod = "10 seconds The" > < contextName can > the logback </ contextName can > <-! Format Output:% date indicates date,% thread indicates that the thread name,% - 5level: level 5 show left character width% msg: log messages,% n newline -> < Property name = "LOG_PATTERN" value = "{% dATE HH: mm : ss.SSS} [Thread%]% {36} Logger -5level% -%% n-MSG " /> ! <- defined log storage path, not the relative path configuration -> < Property name =" the FILE_PATH " value= "D:. /Log/spring-log.%d the MM-dd-YYYY {}% i.log" /> ! <- console output log -> < the appender name = "Console" class = "CH .qos.logback.core.ConsoleAppender " > <-! log level INFO the filter -> < filter class =" ch.qos.logback.classic.filter.ThresholdFilter " > < level > INFO </ level > </ filter > < Encoder > <-! according to the above configuration LOG_PATTERN print log -> < pattern >${LOG_PATTERN}</pattern> </ Encoder > </ appender > <-! Generate a log file every day, for 30 days of log files. rollingFile for segmentation file -> < the appender name = "rollingFile" class = "ch.qos.logback.core.rolling.RollingFileAppender" > < rollingPolicy class = "ch.qos.logback.core.rolling.TimeBasedRollingPolicy" > < fileNamePattern > $ {} the FILE_PATH </ fileNamePattern > <-! Keep 15 Days' Worth of History -> < maxHistory > 30 < <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <!-- 日志文件的最大大小 --> <maxFileSize>2MB</maxFileSize> </timeBasedFileNamingAndTriggeringPolicy> <!-- 超出删除老文件 --> <totalSizeCap>1GB</totalSizeCap> </rollingPolicy> <encoder> <pattern>${LOG_PATTERN}</pattern> </encoder> </appender> <!-- project default level --> <logger name="net.sh.rgface.serive" level="ERROR" /> <!-- 日志输出级别 --> <root level="INFO"> <appender-ref ref="console" /> <appender-ref ref="rollingFile" /> </root> </configuration>
2, the output file, write files prove successful
3、参考地址:https://blog.csdn.net/InnovationAD/article/details/80895508