Step 1: Increase the Logback configuration file
Note: The name is Logback.xml or Logback-spring.xml, recommended is Logback-spring.xml, why. Because the Spring boot framework defaults to looking for a configuration named this, and adds some features.
Step 2:logback.xml Content Configuration
<?xml version= "1.1" encoding= "UTF-8"?> <configuration> <springproperty scope= "context" name= "LogPath" Source= "Logging.path"/> <springproperty scope= "context" name= "ServerName" source= "Server.name"/> <ap Pender name= "Console" class= "Ch.qos.logback.core.ConsoleAppender" > <encoder> <pattern>% Date|%thread|%x{invokeno}|%level|%logger{0}|%msg%n</pattern> </encoder> </appender> < Appender name= "Rollinginfofile" class= "Ch.qos.logback.core.rolling.RollingFileAppender" > <file>${logpath }/${servername}/${servername}.log</file> <rollingpolicy class= " Ch.qos.logback.core.rolling.FixedWindowRollingPolicy "> <filenamepattern>${logpath}/${servername}/${se Rvername}.%i.log</filenamepattern> <minIndex>1</minIndex> <maxIndex>10< /maxindex> </rollingPolicy> <TRIGGERINGPOlicy class= "Ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy" > <maxfilesize>500mb</maxfilesi ze> </triggeringPolicy> <encoder> <pattern>%date|%thread|%x{invokeno}|%le vel|%logger{0}|%msg%n</pattern> </encoder> </appender> <logger name= "Com.alibaba" Level= "${logginglevel}" > <appender-ref ref= "rollinginfofile"/> </logger> <logger name= "Org.apache.ibatis" level= "${logginglevel}" > <appender-ref ref= "rollinginfofile"/> </logger>- -<root level= "${logginglevel}" > <appender-ref ref= "rollinginfofile"/> <appender- Ref ref= "Console"/> </root> </configuration> Note: <springproperty scope= "Context" name= "LogPath" Source= "Logging.path"/> <springproperty scope= "context" name= "ServerName" source= "Server.name"/>
Logging.path and Server.name are all variables that I've defined in the Applicaiton-{profile}.xml, so be sure to use Springproperty to refer to them, otherwise you won't be using them.
Oddly enough, Logginglevel is also defined in the configuration file, but this does not need to be brokered, and can be used directly through ${logginglevel.
Projects can be consulted: Https://github.com/BruceZhangXL/wolf