zoukankan      html  css  js  c++  java
  • ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the clas

    搭建SSM框架运行,打印输出

    ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

    报错提示需要添加 log4j-core的jar包

    <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.11.1</version>
    </dependency>
    

    添加过maven文件后再次启动

    又报错误

    ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2

    这时需要在classpath中添加log4j2.xml文件

    <?xml version="1.0" encoding="UTF-8"?>
    <Configuration status="warn">
        <Appenders>
            <Console name="Console" target="SYSTEM_OUT">
                <PatternLayout pattern="[%-5p] %d %c - %m%n" />
            </Console>
            <File name="File" fileName="dist/my.log">
                <PatternLayout pattern="%m%n" />
            </File>
        </Appenders>
    
        <Loggers>
            <Logger name="mh.sample2.Log4jTest2" level="INFO">
                <AppenderRef ref="File" />
            </Logger>
            <Root level="INFO">
                <AppenderRef ref="Console" />
            </Root>
        </Loggers>
    </Configuration>

    再次运行

  • 相关阅读:
    结合php ob函数理解缓冲机制
    php中的require-once
    PHP面试题基础问题
    Jquery显示与隐藏input默认值的实现代码
    win7下cmd常用命令
    采用cocos2d-x lua 的listview 实现pageview的翻页效果之上下翻页效果
    采用cocos2d-x lua 制作数字滚动效果样例
    luac++
    lua相关笔记
    cornerstone知识点
  • 原文地址:https://www.cnblogs.com/cosmosray/p/13268803.html
Copyright © 2011-2022 走看看