1   /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache license, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the license for the specific language governing permissions and
15 * limitations under the license.
16 */
17 package org.apache.logging.slf4j;
18
19 import java.net.URI;
20
21 import org.apache.logging.log4j.spi.LoggerContext;
22 import org.apache.logging.log4j.spi.LoggerContextFactory;
23 import org.apache.logging.log4j.status.StatusLogger;
24
25 /**
26 *
27 */
28 public class SLF4JLoggerContextFactory implements LoggerContextFactory {
29 private static final StatusLogger LOGGER = StatusLogger.getLogger();
30 private static LoggerContext context = new SLF4JLoggerContext();
31
32 public SLF4JLoggerContextFactory() {
33 // LOG4J2-230, LOG4J2-204 (improve error reporting when misconfigured)
34 boolean misconfigured = false;
35 try {
36 Class.forName("org.slf4j.helpers.Log4jLoggerFactory");
37 misconfigured = true;
38 } catch (final ClassNotFoundException classNotFoundIsGood) {
39 LOGGER.debug("org.slf4j.helpers.Log4jLoggerFactory is not on classpath. Good!");
40 }
41 if (misconfigured) {
42 throw new IllegalStateException("slf4j-impl jar is mutually exclusive with log4j-to-slf4j jar "
43 + "(the first routes calls from SLF4J to Log4j, the second from Log4j to SLF4J)");
44 }
45 }
46
47 @Override
48 public LoggerContext getContext(final String fqcn, final ClassLoader loader, final Object externalContext,
49 final boolean currentContext) {
50 return context;
51 }
52
53 @Override
54 public LoggerContext getContext(final String fqcn, final ClassLoader loader, final Object externalContext,
55 final boolean currentContext, final URI configLocation, final String name) {
56 return context;
57 }
58
59 @Override
60 public void removeContext(final LoggerContext context) {
61 }
62 }

org.slf4j.helpers.Log4jLoggerFactory is not on classpath. Good!的更多相关文章

  1. java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext问题原因及解决方法

    一.错误信息 java.lang.ClassCastException: org.slf4j.impl.Log4jLoggerFactory cannot be cast to ch.qos.logb ...

  2. Atitit.日志系统slf4j的使用

    Atitit.日志系统slf4j的使用 SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar ...

  3. slf4j介绍以及实现原理窥探

    一.概述 slf4j(全称是Simple Loging Facade For Java)是一个为Java程序提供日志输出的统一接口,并不是一个具体的日志实现方案,就好像我们经常使用的JDBC一样,只是 ...

  4. 常见java日志系统的搭配详解:关于slf4j log4j log4j2 logback jul jcl commons-logging jdk-logging

    先看一张图: 是不是有点晕, 晕就对了.这个仅仅是 slf4j 的情况,实际上, 我们不仅要接触到 slf4j ,有时候还会接触其他的日志系统.且看下文分解. 1 直接使用各个日志系统 1.1 直接使 ...

  5. SLF4J multiple

    "C:\Program Files\Java\jdk1.8.0_65\bin\java" -Didea.launcher.port=7537 "-Didea.launch ...

  6. SpringBoot LoggerFactory is not a Logback LoggerContext but Logback is on the classpath

    SpringBoot 在启动项目的时候一起错误: SLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding in ...

  7. slf4j教程

    slf4j只是一个门面(facet),它不包含具体的实现,而是将一些log4j,java.logging等实现包装成统一的接口.借用下图展示了常用日志文件的关系: 通过上面的图,可以简单的理清关系! ...

  8. SLF4J warning or error messages and their meanings(转)

    The method o.a.commons.logging.impl.SLF4FLogFactory#release was invoked. Given the structure of the ...

  9. 实现jul 日志重定向到 slf4j

    需求背景 jul 指的是java.util.logging,是 java 内置的日志模块,目前流行的Java日志组件还包括 jcl(common-logging).slf4j/log4j/logbac ...

随机推荐

  1. session未释放

    客户反映一个关于session的bug,说有了1,2天以后,就无法登陆了. 我们这边试了好几天,都没有出现类似问题,后来没办法,只能远程开会,7点左右和他们通话,偶然发现他们居然直接关remote d ...

  2. LSTM容易混淆的地方

    1 如果只是学习怎么用LSTM,那么可以这么理解LSTM LSTM可以看成一个仓库,而这个仓库有三个门卫,他们的功能分别是 遗忘门.决定什么样的物品需要从仓库中丢弃. 输入门.决定输入的什么物品用来存 ...

  3. VS2017 无法解析的外部符号 __vscwprintf

    我是将VS2012 升级到VS2017,然后对以前的项目重新编译, 就出现了下面错误 错误 LNK2019 无法解析的外部符号 __imp__vsnprintf,该符号在函数 *******中被引用 ...

  4. 第02组 Beta冲刺(1/5)

    队名:無駄無駄 组长博客 作业博客 组员情况 张越洋 过去两天完成了哪些任务 初步任务分配 提交记录(全组共用) 接下来的计划 完善接口文档 还剩下哪些任务 学习软工的理论课 学习代码评估.测试 燃尽 ...

  5. PMP132种工具与技术

    <PMBOK ® 指南>第六版中共包括 132 种工具与技术 <PMBOK ® 指南>使用了以下工具与技术分组:1.数据收集技术.用于从各种渠道收集数据与信息.共有9 种数据收 ...

  6. (三十七)golang--如何获取命令行参数

    1.第一种方式 缺点:参数的接收受输入的顺序所影响. 2.第二种方式(使用flag包)  

  7. 深圳龙华有轨电车BIM项目

    本项目是“龙华有轨电车BIM+GIS运维管理平台“研发组成的内容之一,包含站台.电车.变电所等模型绘制. 龙华区有轨电车是深圳市的一条位于龙华区的有轨电车线路,项目规划了三条线路,总长51公里.试验线 ...

  8. vue+django分离开发的思想和跨域问题的解决

    一.介绍 在前后端分离的开发过程中,会涉及到跨域的问题,比如本次个人使用的Django+vue的框架,在vue对Django进行响应,Django再将响应的数据返回给vue,vue在进行渲染,如果不设 ...

  9. Jsp和Servlet有什么区别?

    Servlet接口中有哪些方法? Servlet接口定义了5个方法,其中前三个方法与Servlet生命周期相关: void init(ServletConfig config) throws Serv ...

  10. 基于WEB的网上购物系统-ssh源码

    基于WEB的网上购物系统主要功能包括:前台用户登录退出.注册.在线购物.修改个人信息.后台商品管理等等.本系统结构如下:(1)商品浏览模块:        实现浏览最新商品        实现按商品名 ...