qq_36325121
爱折腾的Albert
采纳率0%
2018-07-03 02:53 阅读 4.5k

log4j升级到log4j2出现的问题,找不到log4j配置文件

5

下面是控制台打印
显示是已经加了log4j2.xml的,但是还是提示有问题
感觉和这个sfl4j 版本有问题。我用不同版本,也会显示不同的错误日志信息

 2018-07-03 10:47:58,479 RMI TCP Connection(2)-127.0.0.1 ERROR Unable to locate appender "consolePrint" for logger config "com.komlin.modular.*.mapper";

这句是在log4j2.xml里面配置的。报错

 Connected to server
[2018-07-03 10:47:53,893] Artifact SmartCompus:war exploded: Artifact is being deployed, please wait...
Jul 03, 2018 10:47:54 AM org.apache.catalina.loader.WebappClassLoaderBase validateJarFile
信息: validateJarFile(/Users/albert/Workspace/IDEA/SmartCompus/target/SmartCompus/WEB-INF/lib/javax.servlet-api-3.1.0.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Jul 03, 2018 10:47:57 AM org.apache.catalina.startup.TldConfig execute
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2018-07-03 10:47:58,479 RMI TCP Connection(2)-127.0.0.1 ERROR Unable to locate appender "consolePrint" for logger config "com.komlin.modular.*.mapper"
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Jul 03, 2018 10:48:03 AM org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory /usr/local/apache-tomcat-7.0.88/webapps/manager
Jul 03, 2018 10:48:03 AM org.apache.catalina.startup.TldConfig execute
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Jul 03, 2018 10:48:03 AM org.apache.catalina.startup.HostConfig deployDirectory
信息: Deployment of web application directory /usr/local/apache-tomcat-7.0.88/webapps/manager has finished in 138 ms
[2018-07-03 10:48:03,836] Artifact SmartCompus:war exploded: Artifact is deployed successfully
[2018-07-03 10:48:03,836] Artifact SmartCompus:war exploded: Deploy took 9,943 milliseconds
Jul 03, 2018 10:48:04 AM org.apache.jasper.compiler.TldLocationsCache tldScanJar
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

下面是maven的依赖,以及版本

    <properties>
        <spring.version>4.2.5.RELEASE</spring.version>
        <mybatis.version>3.2.8</mybatis.version>
        <slf4j.version>1.7.2</slf4j.version>
        <log4j.version>2.5</log4j.version>
        <mysql.driver.version>5.1.21</mysql.driver.version>
        <commons-fileupload.version>1.3</commons-fileupload.version>
        <servlet.version>3.1.0</servlet.version>
        <spring-mybatis.version>1.2.2</spring-mybatis.version>
        <fastjson.version>1.1.41</fastjson.version>
        <jackson.version>2.3.0</jackson.version>
        <quartz.versison>1.8.5</quartz.versison>
        <httpclient.version>3.1</httpclient.version>
        <jstl.version>1.2</jstl.version>
        <shiro.version>1.2.3</shiro.version>
        <lombok.version>1.16.18</lombok.version>
        <json.version>2.4</json.version>
        <poi.version>3.14</poi.version>
        <gexin.http.version>4.0.1.17</gexin.http.version>
        <maven.pluin.version>2.5.2</maven.pluin.version>
        <druid-version>1.1.10</druid-version>
        <commons-fileupload.version>1.3</commons-fileupload.version>
    </properties>


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

  • weixin_37760377 Wayyyyyyyy 2018-07-03 03:08

    应该是log4j的slf4j的版本不对应 你log4j提高了 slf4应该也相应提高

    点赞 评论 复制链接分享
  • hengmaofu hengmaofu 2018-07-03 03:23

    通过mvn dependency:tree 查看依赖冲突,排除一下

    点赞 评论 复制链接分享
  • qq_42568324 末末的哥哥 2018-07-03 08:28

    log4j升级后相应的升级其他插件

    点赞 评论 复制链接分享
  • qq_31987435 Licon丿Never 2018-07-03 08:59

    看看是不是子pom和父pom声明重复,结果版本不一致导致的。

    点赞 评论 复制链接分享
  • hadues 技术宅星云 2019-09-20 14:57

    必须放到这个路径下才行:

    src/main/resources/log4j2.xml

    加载顺序如下:

    1.查看系统属性log4j.configurationFile是否配置了,如果配置了使用ConfigurationFactory
    2.如果没有配置,那么查找log4j2-test.properties
    3.如果也没找到,那么检查是否有log4j2-test.yaml或者log4j2-test.yml
    4.如果也没找到,那么检查是否有log4j2-test.json或者log4j2-test.jsn
    5.如果也没找到,那么检查是否有log4j2-test.xml
    6.如果也没找到,那么检查是否有log4j2.properties
    7.如果也没找到,那么检查是否有log4j2.yaml或log4j2.yml
    8.如果也没找到,那么检查是否有log4j2.json或log4j2.jsn
    9.如果也没找到,那么检查是否有log4j2.xml
    10.如果也没知道,那么使用默认的DefaultConfiguration,只输出到控制台
    

    更多参考我的博文:

    关于Log4j 1.x 升级Log4j 2.x 那些事

    点赞 评论 复制链接分享

相关推荐