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. USB鼠标抓包数据(转)

    https://blog.csdn.net/zqixiao_09/article/details/53056854

  2. Mac流程图的软件

    里面有破解机器,按照步骤一步步来就可以了 https://www.zhinin.com/omnigraffle_pro-mac.html

  3. 基于MicroPython:TPYBoard心率监测器

    转载请注明文章来源,更多教程可自助参考docs.tpyboard.com,QQ技术交流群:157816561,公众号:MicroPython玩家汇 一.前言 这几年智能穿戴设备大火,尤其是手环类,从A ...

  4. Django学习笔记(14)——AJAX与Form组件知识补充(局部钩子和全局钩子详解)

    我在之前做了一个关于AJAX和form组件的笔记,可以参考:Django学习笔记(8)——前后台数据交互实战(AJAX):Django学习笔记(6)——Form表单 我觉得自己在写Django笔记(8 ...

  5. 《 .NET并发编程实战》扩展阅读 - 元胞自动机 - 1 - 为什么要学元胞自动机

    先发表生成URL以印在书里面.等书籍正式出版销售后会公开内容.

  6. JavaScript addEventListener()事件监听方法

    addEventListener()方法将事件处理程序附加到指定的元素. addEventListener()方法将事件处理程序附加到元素,而不覆盖现有的事件处理程序. 您可以向一个元素添加许多事件处 ...

  7. LeetCode: 404.左叶子节点

    计算给定二叉树的所有左叶子之和. 示例: 3 / \ 9 20 / \ 15 7 在这个二叉树中,有两个左叶子,分别是 9 和 15,所以返回 24 解析 我们需要找到这样的节点 属于叶子节点 属于父 ...

  8. Oh-My-Zsh的配置与使用

    什么是Shell? 相对于内核来说,Shell是Linux/Unix的一个外壳,它负责外界与Linux内核的交互,接收用户或其他应用程序的命令,然后把这些命令转化成内核能理解的语言,传给内核,内核是真 ...

  9. vue -全局组件和局部组件

    1.全局组件:Vue.component('标签名', 构造器名) Vue.component('mycpn', cpnC) 注:这种注册组件的方式是全局组件,可以在多个Vue实例中使用. 2.局部组 ...

  10. foreachRDD

    需求: 将统计结果写入到MySQL create table wordcount( word varchar(50) default null, wordcount int(10) default n ...