创建springBoot项目(分三步,依赖,配置,引导类)
pom文件中添加依赖application.yaml 配置文件com.itheima day10_mongodb_springboot 1.0-SNAPSHOT org.springframework.boot spring-boot-starter-parent 2.1.3.RELEASE org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-logging org.mongodb mongo-java-driver 3.10.1 org.springframework.boot spring-boot-starter-log4j2 org.apache.logging.log4j log4j-core 2.9.1 org.apache.logging.log4j log4j-nosql 2.9.0
# 项目端口号 server: port: 8080 # 日志配置 logging: config: classpath:log4j2.xmlMyConfiguration 引导类
@SpringBootApplication
public class MyConfiguration {
public static void main(String[] args) {
SpringApplication.run(MyConfiguration.class,args);
}
}
到此,springboot项目就可以正常启动了
然后是集成log4j2的日志框架
整体文件放置如下



