您现在的位置是:网站首页>JavaJava

Spring Boot采用yml的方式配置 Log4j2 日志文件

左鹏03-04 17:04:09Java638人已围观

简介参考:https://blog.csdn.net/u010598111/article/details/80556437参考此博客后如果出现以下异常: java.lang.IllegalStateException: Could not initialize Logback logging from classpath:log4j2.yml1 则是由于:spring boot默认的是logback

参考:https://blog.csdn.net/u010598111/article/details/80556437
参考此博客后如果出现以下异常:

java.lang.IllegalStateException: Could not initialize Logback logging from classpath:log4j2.yml1

则是由于:spring boot默认的是logback日志管理,配置log4j2之前需要移除logback相关包,官方文档的pom.xml配置是

<!--Spring-boot中去掉logback的依赖-->
<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>

发现并不能完全移除logback。
pom.xml改为如下即可:

<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>

 

文章评论

    请先说点什么
    热门评论
    0人参与,0条评论
    正在载入评论列表...

    站点信息

    • 建站时间:2018-09-18
    • 网站程序:Spring Boot
    • 主题模板:《今夕何夕》
    • 文章统计:104条
    • 微信公众号:扫描二维码,关注我们
    登陆您的账户