<?XML version= "1.0" encoding= "UTF-8"?><ConfigurationScan= "true"Scanperiod= "Seconds"> <Contextname>Server</Contextname> <!--Log Path - < Propertyname= "Log_home"value= "${log_home}" /> <!--log file Output - <Appendername= "Rollingfileout"class= "Ch.qos.logback.core.rolling.RollingFileAppender"> <Encoding>UTF-8</Encoding> <Prudent>True</Prudent> <Rollingpolicyclass= "Ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <Filenamepattern>${log_home}/auto-%d{yyyy-mm-dd}.%i.log</Filenamepattern> <maxhistory>30</maxhistory> <Timebasedfilenamingandtriggeringpolicyclass= "Ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <MaxFileSize>10MB</MaxFileSize> </Timebasedfilenamingandtriggeringpolicy><!-- - <!--<triggeringpolicy class= "Ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy" > <maxfilesiz E>0.1mb</maxfilesize> </triggeringPolicy> - </Rollingpolicy> <Encoder><!--temporarily use the original format first - <pattern>%date%level [%thread]%logger.%class{0}#%method [%file:%line]%msg%n</pattern> <CharSet>GBK</CharSet> </Encoder> </Appender> <!--defining the console output - <Appendername= "ConsoleOut"class= "Ch.qos.logback.core.ConsoleAppender"> <Encoder> <pattern>%date%level [%thread]%logger.%class{0}#%method [%file:%line]%msg%n</pattern> </Encoder> </Appender> <!--<logger name= "App" > <appender-ref ref= "rollingfileout"/> </logger> - <Loggername= "Org.apache.ibatis.io.ResolverUtil" Level= "WARN"/> <Loggername= "Org.mybatis.spring.SqlSessionUtils" Level= "WARN"/> <Loggername= "Org.mybatis.spring.SqlSessionFactoryBean" Level= "WARN"/> <Loggername= "Org.mybatis.spring.transaction.SpringManagedTransaction" Level= "WARN"/> <Loggername= "Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" Level= "WARN"/> <Loggername= "Org.springframework.jdbc.datasource.DataSourceTransactionManager" Level= "WARN"/> <Loggername= "Org.springframework.jdbc.datasource.DataSourceUtils" Level= "WARN"/> <Loggername= "Org.springframework.scheduling.quartz.LocalDataSourceJobStore" Level= "WARN"/> <Loggername= "Org.quartz.impl.jdbcjobstore.StdRowLockSemaphore" Level= "WARN"/> <Loggername= "Org.apache.http.wire" Level= "WARN"/> <Root Level= "Debug"><!--TRACE, DEBUG, INFO, WARN, ERROR, all, OFF - <Appender-refref= "ConsoleOut" /> <!--comment out when you deploy to the server - <Appender-refref= "Rollingfileout" /> </Root> </Configuration>
Advantage: You can print out the debug level of SQL statements and other information, and filter out some jar package unrelated log (level= "WARN"), to avoid the log file is too large.
Logback Log configuration File code example