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>

    再次运行

  • 相关阅读:
    时间编程
    移动文件流的读写指针---fseek
    Xadmin添加用户小组件出错render() got an unexpected keyword argument 'renderer
    xadmin安装
    Django:Python3.6.2+Django2.0配置MySQL 转载
    gitignore文件不生效
    django图片上传修改图片名称
    python3 提示sqlite模块不存在
    Django-admin列表展示上传图片
    django使用admin站点上传图片
  • 原文地址:https://www.cnblogs.com/cosmosray/p/13268803.html
Copyright © 2011-2022 走看看