java:打印日志log
java:打印日志
·
场景一:打印日志
方法
//在main外:(任选一种即可)
//方法一:(一般用法)
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger log = LoggerFactory.getLogger(类名.class);
//方法二:
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class 类名 {}
//在main内:
log.info("开始记录日志");
对应依赖
//方法一:
implementation 'org.slf4j:slf4j-api:1.7.32'
implementation 'com.alibaba:fastjson:2.0.2'//好像不用这个hhh
//方法二:
implementation 'org.projectlombok:lombok:1.18.18'
场景二:在此基础上打印传输协议的指令信息
方法:添加依赖
implementation 'org.springframework.boot:spring-boot-starter-parent:2.6.3'
implementation 'org.springframework.boot:spring-boot-starter-parent:2.6.3'
implementation 'org.springframework.boot:spring-boot-starter-web:2.6.3'
implementation 'org.springframework.boot:spring-boot-starter-tomcat:2.6.3'
结果:
更多推荐
所有评论(0)