今天在学习structs2  2.5.5的版本的时候碰到2个问题。第一个网上下的包里面差log4j-core这个包。

虽然程序可以运行,但控制台会报这个错误。

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

在添加了这个包后在再次运行程序。

控制台提示

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

找不到log4j2的配置文件

网上google之。找到文档。原来只要在classpath下的目录添加一个log4j2.xml。就可以了

  1.  
    <?xml version="1.0" encoding="UTF-8"?>
  2.  
    <Configuration status="warn">
  3.  
                <Appenders>
  4.  
                            <Console name="Console" target="SYSTEM_OUT">
  5.  
                                        <PatternLayout pattern="[%-5p] %d %c - %m%n" />
  6.  
                            </Console>
  7.  
                            <File name="File" fileName="dist/my.log">
  8.  
                                        <PatternLayout pattern="%m%n" />
  9.  
                            </File>
  10.  
                </Appenders>
  11.  
     
  12.  
                <Loggers>
  13.  
                            <Logger name="mh.sample2.Log4jTest2" level="INFO">
  14.  
                                        <AppenderRef ref="File" />
  15.  
                            </Logger>
  16.  
                            <Root level="INFO">
  17.  
                                        <AppenderRef ref="Console" />
  18.  
                            </Root>
  19.  
                </Loggers>
  20.  
    </Configuration>

这里为什么这样配置就不说了,可以去查阅log4j2的文档。

在次运行程序,控制台没有错误提示了

我果然还是java菜鸟一个啊,这里只是自己的学习记录,哈哈,大神别喷。

原文:http://xtceetg.blog.51cto.com/5086648/1877001

最新文章

  1. IIS 设置默认首页静态页,无静态页,走路由
  2. 操作系统开发系列—13.c.进程之中断重入
  3. 彻底解决Android SDK Manager更新慢的问题
  4. peak num
  5. ubuntu下配置hosts
  6. 【原创】【ViewFlow+GridView】Parameter must be a descendant of this view问题分析
  7. 使用TypeDescriptor给类动态添加Attribute
  8. vs工程链接出现error LNK2005...already defined
  9. IE比Chrome强的一个地方
  10. rsync 只是测试,请看下一篇
  11. Linux - 简明Shell编程14 - 操作符(Operator)
  12. 1.5 sleep()方法
  13. vitual dom实现(转)
  14. linux下GPRS模块使用AT命令实现拨接电话,发中英文短信
  15. CentOS 7.0关闭服务器的防火墙服务命令
  16. react ref获取dom对象
  17. 学习MFC的建议
  18. node+mongoose使用例子
  19. Oracle PLSQL Demo - 05.WHILE循环[WHILE LOOP]
  20. 没有Home键之后的iPhone会是什么样子?

热门文章

  1. Ecplise中Junit4单元测试的基本用法
  2. 进入BIOS中,设置U盘启动
  3. 【算法】[leetcode] permutations的讨论(转载)
  4. Java面向对象----String对象的声明和创建
  5. find 使用搜集
  6. 2018-9-19-Roslyn-通过-Nuget-管理公司配置
  7. vb.net机房收费系统——存储过程
  8. oracle函数 NEW_TIME(dt1,c1,c2)
  9. js获取dom节点
  10. Ubuntu16.04.3深度学习环境搭建