springboot中logback和log4j冲突,保留log4j

首先在spring-boot-starter-web中排除spring-boot-starter这个包
然后在spring-boot-starter中排除spring-boot-starter-logging包,此时logback包就被排除了.因为logbak包的上一级parent为spring-boot-starter包

<!--排除spring-boot-starter-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <!-- 去除旧log依赖 -->
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--引入spring-boot-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://www.cnblogs.com/eternityz/p/12241592.html

时间: 2024-08-05 01:39:35

springboot中logback和log4j冲突,保留log4j的相关文章

SpringBoot中logback.xml使用application.yml中属性

教你如何使用 springProfile 与 springProperty 让你的logback.xml 配置显得更有逼格,当别人还在苦苦挣扎弄logback-{profile}.xml的时候 你一个文件就搞定了- - springProfile 该 <springProfile> 标签允许我们更加灵活配置文件,可选地包含或排除配置部分.元素中的任何位置均支持轮廓部分.使用该name属性指定哪个配置文件接受配置.可以使用逗号分隔列表指定多个配置文件. <springProfile nam

在eclipse中运行wordcount,控制台打印log4j警告

log4j:WARN No appenders could be found for logger (org.apache.hadoop.util.Shell).log4j:WARN Please initialize the log4j system properly.log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 解决办法: 将/usr/local/hadoop/etc/h

Springboot中的日志管理

本案例中可以了解,怎么配置日志的输出路径,输出格式(比如说zip格式),按日期进行划分(今天的日志输出为一个文件,明天的日志输出到另一个文件),在按日期划分的同时又按文件大小划分(比如说每天的日志记录很多,希望一个日志文件为5GB...),上面的功能,看完这篇都能实现.(参考链接超有用,建议直接下拉打开链接) Slf4j 日志管理的抽象接口 Log4j,log4j2,logback,日志管理框架,日志管理实现 Springboot中pom.xml,若引入了web的起步依赖,不需要再引入日志管理相

springboot配置logback日志

springboot配置logback日志 java web 下有好几种日志框架,比如:logback,log4j,log4j2(slj4f 并不是一种日志框架,它相当于定义了规范,实现了这个规范的日志框架就能够用 slj4f 调用).本篇主要说明spring boot配置logback springboot配置日志框架之前,要先取消springboot默认的日志框架 一.在pom.xml中加入取消默认日志框架 <dependency> <groupId>org.jxls</

SpringBoot中的日志配置

SpringBoot支持JavaUtilLogging,Log4J,Log4J2和Logback作为日志框架,无论使用哪种日志框架,SpringBoot已为当前使用日志框架的控制台输出及文件输出做好了配置. 默认情况下,SpringBoot使用Logback作为日志框架 配置日志级别: logging.file=D:/mylog/log.log 配置日志文件,格式为logging.level.包名=级别: logging.level.org.springframework.web=DEBUG 原

Log4j – Configuring Log4j 2 - Apache Log4j 2

Apache Log4j 2 ? Logging Wiki Apache Logging Services Sonar   Configuration Inserting log requests into the application code requires a fair amount of planning and effort. Observation shows that approximately 4 percent of code is dedicated to logging

log4j日志文件 log4j.xml log4j.properties配置

1,导入log4j  jar包; 2,配置log4j.xml或log4j.properties文件; ----------------------------------------------------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuratio

log4j.xml与log4j.dtd的配置详细说明与使用

1.log4j.dtd .dtd文件是对相应.xml进行约束验证用的.这里不做介绍了,详细见上一篇关于dtd的介绍:xml基础.DTD验证.Schema验证 log4j.dtd的文件: <?xml version="1.0" encoding="UTF-8" ?> <!-- Authors: Chris Taylor, Ceki Gulcu. --> <!-- Version: 1.2 --> <!-- A configur

log4j配置参考手册:log4j.properties和log4j.xml两种格式

log4j是Java Web开发中,最常用的日志组件之一.网上关于log4j的配置满天飞,我主要是从网上学习的配置.之前的很多年,主要使用log4j.properties这种格式.后来,项目中boss使用了log4j.xml这种配置.   关于xml配置,之前也用过,主要觉得麻烦,而且还要手动配置listener,所以基本不用.   和boss交流了下,发现xml格式的配置,语法更全面.我主要发现了2种"高端用途" :1.业务日志与系统日志相分离.(这个比较有价值)2.配置过滤器. (