今天部署代码到 linux 服务器,用ant 试运行一下,发现没有log文件输出, 但是在Eclipse中却没问题.
然后在本地DOS命令行里运行一下ant, 还是没有log文件. 随即baidu + google找到一个方法
1. 一种比较麻烦的方法
先设置环境变量
set ANT_OPTS=-Dlog4j.debug -Dlog4j.configuration=file:///D:/CVS/myProject/classes/log4j.properties
再加参数-listener 运行ant
ant -listener org.apache.tools.ant.listener.Log4jListener target名字
以后直接运行 "ant target名字" 就可以了.
2. 上面的方法太麻烦, 而且是将ant的所有输出都打到log里了. 所以就想在程序中强制写死读取log4j.properties文件.
ant运行却报了一个错, [java] java.io.FileNotFoundException: file:\D:\CVS\myProject\lib\axis-ant.jar!\log4j.properties
奇怪! 怎么会报这里错误? 把axis-ant.jar删掉! 再试一次, OK, log文件出来了!
打开axis-ant.jar, 发现里面有个log4j.properties文件, 呵呵, 看来找到问题了.
# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootCategory=INFO, CONSOLE
#log4j.rootCategory=INFO, CONSOLE, LOGFILE
这就是前3行,后面的不用看也明白了, 它只向CONSOLE输出.
ant编译的时候在内存中把jar都解开了?
log4j怎么就鬼使神差的读取了axis-ant.jar的log4j.properties ?
分享到:
相关推荐
很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很实用很...
struts+hibernate+spring+xdoclet+ant+log4j 技术整合,有实例参考,最好的框架!
标签:ant-apache-log4j-1.6.5.jar.zip,ant,apache,log4j,1.6.5,jar.zip包下载,依赖包
ant-apache-log4j-1.7.1-13.el6.i686.rpm是centos依赖包。
标签:ant-apache-log4j-1.9.3.jar,ant,apache,log4j,1.9.3,jar包下载,依赖包
标签:ant-apache-log4j-1.7.0.jar,ant,apache,log4j,1.7.0,jar包下载,依赖包
标签:ant-apache-log4j-1.7.1.jar,ant,apache,log4j,1.7.1,jar包下载,依赖包
标签:ant-apache-log4j-1.9.1.jar,ant,apache,log4j,1.9.1,jar包下载,依赖包
标签:ant-apache-log4j-1.8.3.jar,ant,apache,log4j,1.8.3,jar包下载,依赖包
标签:ant-apache-log4j.jar.zip,ant,apache,log4j,jar.zip包下载,依赖包
标签:ant-apache-log4j-1.8.0.jar,ant,apache,log4j,1.8.0,jar包下载,依赖包
标签:ant-apache-log4j-1.8.1.jar,ant,apache,log4j,1.8.1,jar包下载,依赖包
标签:ant-apache-log4j-1.9.2.jar,ant,apache,log4j,1.9.2,jar包下载,依赖包
官方版本,亲测可用
标签:ant-jakarta-log4j-1.6.jar.zip,ant,jakarta,log4j,1.6,jar.zip包下载,依赖包
标签:ant-apache-log4j-1.6.4.jar.zip,ant,apache,log4j,1.6.4,jar.zip包下载,依赖包
ssh2 spring hibernate struts2 log4j ant
标签:ant-apache-log4j-1.8.4.jar,ant,apache,log4j,1.8.4,jar包下载,依赖包
标签:ant-apache-log4j-1.9.0.jar,ant,apache,log4j,1.9.0,jar包下载,依赖包
标签:ant-apache-log4j-1.9.4.jar,ant,apache,log4j,1.9.4,jar包下载,依赖包