提交 1fc96b2e 编写于 作者: S studyingpanda

chen

上级 45175e34
......@@ -24,6 +24,13 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......
# 设置日志级别
logging.level.root=WARN
# 设置日志文件
logging.file=C:\\logs\\spring-boot-log.log
# 设置日志目录
logging.path=C:\\logs
package com.imooc.springbootlog;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.test.context.SpringBootTest;
import lombok.extern.slf4j.Slf4j;
@SpringBootTest
@Slf4j // 添加日志输出注解
class LogTest {
// 不再需要定义 logger
// private Logger logger = LoggerFactory.getLogger(this.getClass());
@Test
void testPrintLog() {
// 直接使用log输出日志
log.trace("trace log");
log.debug("debug log");
log.info("info log");
log.warn("warn log");
log.error("error log");
}
}
\ No newline at end of file
package com.imooc.springbootlog;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SpringBootLogApplicationTests {
@Test
void contextLoads() {
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册