转自:
http://www.java265.com/JavaFramework/SpringBoot/202206/3806.html
下文笔者讲述springboot集成log模块的方法分享,如下所示- 实现思路:
- 1.引入相应的jar包
- 2.配置相应的xml文件
复制代码 例:- Maven依赖
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-logging</artifactId>
- </dependency>
- <?xml version="1.0" encoding="UTF-8" ?>
- <configuration scan="true" scanPeriod="60 seconds" debug="false">
-
- <springProperty scope="context" name="appname" source="logback.appname"/>
- <springProperty scope="context" name="logdir" source="logback.logdir"/>
- <contextName>${appname}</cpntextName>
- <appender name="consoleLog" >
- <layout >
- <pattern>%d{yyyy-MM-dd} %d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern>
- <appender name="fileLog" >
-
- <File>${logdir}/${appname}.log</File>
-
- <rollingPolicy >
-
- <FileNamePattern>${logdir}/${appname}-%d{yyyy-MM-dd}.log</FileNamePattern>
-
- <maxHistory>90</maxHistory>
-
-
- </rollingPolicy>
-
- <encoder>
- <charset>UTF-8</charset>
- <pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</pattern>
- <root level="info">
- <appender-ref ref="consoleLog" />
- <appender-ref ref="fileLog" />
- </configuration>
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |