首先 ,引入log4j2的starter,将logback.xml改为log4j2的配置文件,文件格式自选吧,xml,json,yaml都可以。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j2</artifactId> </dependency>
1、如果项目中只引入了web的starter,则可以在web starter中排除掉logging,然后引入,log4j2的starter
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency>
2、如果项目中引入的不止web starter,比如有amqp的starter则上述方式失效,此时我们需要在spring-boot-starter中排除logging的依赖。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> </exclusions> </dependency>
转载于:https://my.oschina.net/fshuqing/blog/2996800
最后
以上就是热情夏天最近收集整理的关于Springboot默认日志logback切换为log4j2的全部内容,更多相关Springboot默认日志logback切换为log4j2内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复