logback.xml文件
需要在配置文件中指定log.path路径
spring.application.name为项目名字
<configuration>
<springProperty scope="context" name="LOG_HOME" source="log.path"/>
<springProperty scope="context" name="APPLICATION_NAME" source="spring.application.name"/>
<property name="CONSOLE_LOG_PATTERN"
value="%yellow(%date{yyyy-MM-dd HH:mm:ss}) |%highlight(%-5level) |%blue(%thread) |%blue(%file:%line) |%green(%logger) |%cyan(%msg%n)"/>
<!--控制台-->
<appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<appender name="consoleFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_HOME}/${APPLICATION_NAME}-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<maxFileSize>1000MB</maxFileSize>
<maxHistory>90</maxHistory>
<totalSizeCap>30GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<logger name="org.hibernate.SQL" level="DEBUG" additivity="false">
<appender-ref ref="consoleAppender" />
<appender-ref ref="consoleFileAppender" />
</logger>
<root level="INFO">
<appender-ref ref="consoleAppender"/>
<appender-ref ref="consoleFileAppender"/>
</root>
</configuration>