首页 技术 正文
技术 2022年11月12日
0 收藏 772 点赞 3,329 浏览 1994 个字

Spring框架 (log4j :WARN No appenders could be found for logger log4j:WARN Please initialize the log4j system properly.)问题解决

Spring框架需要的jar包


1、Spring压缩包中的四个核心JAR包

beans 、context、core 和expression

下载地址:

https://pan.baidu.com/s/1qXLHzAW

2、以及日志jar包

commons-logging 和log4j

下载地址:

https://pan.baidu.com/s/1mimTW5i

3、再增加一个

spring-aop-5.0.1.RELEASE.jar (用于注解,在Spring-framework库中包含)

4、再增加

spring-aspects-5.0.1.RELEASE.jar (在Spring-framework库中包含)

aspectjweaver-1.8.12.jar (官方下载地址 http://mvnrepository.com/artifact/org.aspectj/aspectjweaver)

aopalliance-1.0.jar            (官方下载地址 http://mvnrepository.com/artifact/aopalliance/aopalliance/1.0)


就位后,日志的jar包实际上以安装,却没有发挥作用,还需要把log4j的配置文件复制到src下,没有配置文件不知道用什么格式,如何输出

日志配置文件log4j.properties文件中内容如下:

#日志等级#TRACE:详细等级,堆栈信息#debug:类似于System.out.print#info:类似于Hibernate的show_sql#warn:不影响运行, 只是提示#error:出现异常#全局日志等级配置,输出位置log4j.rootLogger=info,stdout,logfile#stdout控制器log4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.Target=System.outlog4j.appender.stdout.layout=org.apache.log4j.PatternLayout#输出格式log4j.appender.stdout.layout.ConversionPattern=%d %p [%c]:%L - %m%n#文件路径输出log4j.appender.logfile=org.apache.log4j.RollingFileAppender#默认输出到tomcat的根路径或者运行测试工程的根路径log4j.appender.logfile.File=pss.loglog4j.appender.logfile.MaxFileSize=512KB# Keep three backup files.log4j.appender.logfile.MaxBackupIndex=3# Pattern to output: date priority [category] - messagelog4j.appender.logfile.layout=org.apache.log4j.PatternLayoutlog4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - %m%n

配置完成后,再次执行,得到结果不同了,没有Warning了

2017-11-23 11:08:04,354 INFO [org.springframework.context.support.ClassPathXmlApplicationContext]:589 - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@19747cc: startup date [Thu Nov 23 11:08:04 CST 2017]; root of context hierarchy
2017-11-23 11:08:04,693 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader]:316 - Loading XML bean definitions from class path resource [aop.xml]
This is AdviceBook's before()...............
This is AdviceBook's front()...............
This is Book's fun()..............
This is AdviceBook's end()...............
This is AdviceBook's after()...............

日志级别看更详细信息可以用debug,显示会更细致。

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,082
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,556
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,406
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,179
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,815
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898