zoukankan      html  css  js  c++  java
  • 解决java log4j 配置log4jCaused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager

    前提安装http://mirror.bit.edu.cn/apache/logging/log4j/2.11.2/apache-log4j-2.11.2-bin.zip

    Buildpath 配置add extend jar :   log4j-1.2.17.jar

    project/src/下 新建log4j配置文件

    安装完成配置完后依然报错Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.LogManager

    解决:查看原来是有2个含有 org.apache.logging.log4j.LogManager 类的的包导致一个是之前接口httpclent-api-log4j的,一个是上面下载的

    删除http-api-log4j问题解决

    送上配置log4.jproperties

    ### log output control D is debug log output is or not ,E is ERROR OUTPUT is or not control by have D ,E manual control
    log4j.rootLogger = error,stdout,D,E

    ### console logs ###
    log4j.appender.stdout = org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.Target = System.out
    log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n

    ### debug log ###
    log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
    log4j.appender.D.File = ./logs/debug/debug.log
    log4j.appender.D.Append = true
    log4j.appender.D.Threshold = DEBUG
    log4j.appender.D.layout = org.apache.log4j.PatternLayout
    log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n

    ###error logs ###
    log4j.appender.E = org.apache.log4j.DailyRollingFileAppender
    log4j.appender.E.File = ./logs/error/error.log
    log4j.appender.E.Append = true
    log4j.appender.E.Threshold = ERROR
    log4j.appender.E.layout = org.apache.log4j.PatternLayout
    log4j.appender.E.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n

    ---------------------

  • 相关阅读:
    迷宫广搜
    通过地址获取百度地图经纬度
    图片上传存储数据库
    spring boot加载配置文件的顺序
    阿里 短信认证
    spring boot properties文件与yaml文件的区别
    springboot pom问题及注解
    手机短信认证
    获取class对象的三种方法以及通过Class对象获取某个类中变量,方法,访问成员
    关于mysql优化问题
  • 原文地址:https://www.cnblogs.com/SunshineKimi/p/10540376.html
Copyright © 2011-2022 走看看