项目整体
1、配置pom打包
2、书写logback-spring.xml
<configuration><property name="LOGS" value="./ydx-emms-dataform/logs"/><appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"><encoder><pattern>%d{yyyy-MM-dd HH:mm:ss} - %msg%n</pattern></encoder></appender><appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender"><file>${LOGS}/myapp.log</file><encoder><pattern>%d{yyyy-MM-dd HH:mm:ss} - %msg%n</pattern></encoder><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><!-- 每天滚动生成日志文件 --><fileNamePattern>${LOGS}/archived/datapro-%d{yyyy-MM-dd}.%i.log</fileNamePattern><!-- 保留最近7天的日志 --><maxHistory>7</maxHistory><!-- 设置每个日志文件的最大大小 --><timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><maxFileSize>100MB</maxFileSize></timeBasedFileNamingAndTriggeringPolicy></rollingPolicy></appender><root level="info"><appender-ref ref="CONSOLE"/><appender-ref ref="RollingFile"/></root></configuration>
3、配置文件指定级别和路径
完工