- 浏览: 216167 次
- 性别:
- 来自: 沈阳
-
文章分类
- 全部博客 (216)
- struts2 (21)
- IE (5)
- 火影 (1)
- HTML (4)
- 社会科学 (0)
- 心得收藏 (1)
- ExtJS (5)
- 缩略语 (1)
- 操作系统相关 (11)
- C相关 (1)
- 硬件 (1)
- working (2)
- IBM (8)
- JAVA (29)
- 其它 (4)
- 随笔 (8)
- web开发 (9)
- oracle (25)
- Apache (16)
- spring (6)
- struts1 (2)
- JS (30)
- jsp&servlet (18)
- MYSQL (6)
- 外语 (3)
- jQuery (1)
- 动感相关 (1)
- PHP (3)
- IT生活 (4)
- AJAX (4)
- POI (2)
- oracle jdbc (1)
- tomcat (5)
- SQL (2)
- sourceforge (1)
- s2sh (0)
- hibernate (2)
- 笔记 (4)
- XML (1)
- junit (1)
- MyEclipse (1)
- Exception (1)
- win7 (1)
- svn (1)
- maven (1)
- sonatype (1)
- sonatype-works (1)
- nexus (1)
最新评论
-
youjianbo_han_87:
直接在国际化配置里配置就可以,不用重写。
struts2 文件上传自定义信息提示 -
来利强:
很好啊,取 时、分 时好乱啊
oracle extract -
younglibin:
这些东西 在 那个jar中,那个文件能查的到?
struts2 下载配置contentType属性 -
uule:
木看懂!木看懂!
struts2 文件上传自定义信息提示 -
happyxing:
问题相同,我也纠结
oracle动态表名
转自:http://eoasis.iteye.com/blog/644290
webroot
Web app root system property already set to different value: 'webapp.root'
文章分类:Java编程
在web.xml有几个条目和log4j有关,它们是:
1.
- <context-param>
- <param-name>webAppRootKey</param-name>
- <param-value>petclinic.root</param-value>
- </context-param>
<context-param> <param-name>webAppRootKey</param-name> <param-value>petclinic.root</param-value> </context-param>
2.
- <context-param>
- <param-name>log4jConfigLocation</param-name>
- <param-value>/WEB-INFclasseslog4j.properties</param-value>
- </context-param>
<context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INFclasseslog4j.properties</param-value> </context-param>
3.(该条目在petclinic中被注释掉了)
- <listener>
- <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
- </listener>
<listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener>
我们知道,在web-application中使用log4j,有很多配置方式:
a.
用servlet或者ServletContextListener对log4j做配置。通常,你不需要亲自编写servlet或者 listener,比如直接利用log4j的com.apache.jakarta.log4j.Log4jInit类,Spring的 org.springframework.web.util.Log4jConfigServlet和 org.springframework.web.util.Se
rvletContextListener,这种方式配置灵活,可以通过参数条目自行指定log4j.properties的位置。
b.
把log4j 的默认配置文件(log4j.properties)放在classpath中,通常是/web-inf/classes目录下.这种方式是log4j的 默认配置方式,无须其他配置。缺点就是无法灵活的通过配置文件来指定log4j.properties的文件位置。在我们的petclinic项目中,因 为listener条目被注释,所以采用的也是这种缺省方式。
现在我们考虑listener条目没有被注释的情况,这种情况和注册Log4jConfigServlet的目的是一样的,只是必须在支持listener的servlet container中使用。
找到.Log4jConfigServlet和ServletContextListener的源码,他们都在适当的地方 (callback method)调用了Log4jWebConfigurer.initLogging(getServletContext()); 定位到这个方法,第一句就是:WebUtils.setWebAppRootSystemProperty(servletContext);再定位到该方法,方法很短:
- public static void setWebAppRootSystemProperty(ServletContext servletContext) throws IllegalStateException {
- String param = servletContext.getInitParameter(WEB_APP_ROOT_KEY_PARAM);
- String key = (param != null ? param : DEFAULT_WEB_APP_ROOT_KEY);
- String oldValue = System.getProperty(key);
- if (oldValue != null) {
- throw new IllegalStateException("WARNING: Web app root system property already set: " + key + " = " +
- oldValue + " - Choose unique webAppRootKey values in your web.xml files!");
- }
- String root = servletContext.getRealPath("/");
- if (root == null) {
- throw new IllegalStateException("Cannot set web app root system property when WAR file is not
- expanded");
- }
- System.setProperty(key, root);
- servletContext.log("Set web app root system property: " + key + " = " + root);
- }
public static void setWebAppRootSystemProperty(ServletContext servletContext) throws IllegalStateException { String param = servletContext.getInitParameter(WEB_APP_ROOT_KEY_PARAM); String key = (param != null ? param : DEFAULT_WEB_APP_ROOT_KEY); String oldValue = System.getProperty(key); if (oldValue != null) { throw new IllegalStateException("WARNING: Web app root system property already set: " + key + " = " + oldValue + " - Choose unique webAppRootKey values in your web.xml files!"); } String root = servletContext.getRealPath("/"); if (root == null) { throw new IllegalStateException("Cannot set web app root system property when WAR file is not expanded"); } System.setProperty(key, root); servletContext.log("Set web app root system property: " + key + " = " + root); }
从代码看出,该方法其实就是把该web application的根目录的绝对文件路径作为属性保存在 System的属性列表中。该属性的名字,由web.xml文件中的名为"webAppRootKey"的参数值指出。如果不在web.xml中定义 webAppRootKey参数,那么属性名就是缺省的"webapp.root".在我们的petclinic项目中已经定义了 webAppRootKey参数,其值为"petclinic.root",因此,属性的名字就是"petclinic.root".
再回到Log4jWebConfigurer.initLogging(getServletContext()),接下来的行为是从web.xml中获取 log4jConfigLocation和log4jRefreshInterval.前者指出log4j配置文件(有可能是xml格式)的位置和名字, 后者则指出重新都取配置文件的时间间隔.然后调用Log4jConfigurer.initLogging()方法对log4j做配置。
从Log4jConfigurer.initLogging()方法我们可以看到,针对不同格式的配置文件(properties或者xml), Log4jConfigurer采用不同的lo4j configurator类做配置,例如DOMConfigurator或者 PropertyConfigurator。
至此,关于petclinic中关于log4j的配置,我们已经基本上弄清楚了。
可是System对象中的petclinic.root属性在什么时候使用呢?在web-inf/classes下面的log4j.properties文件中,有这么一句:log4j.appender.logfile.File=${petclinic.root}/WEB-INF/petclinic.log
这样,我们就用上了petclinic.root属性了。从上面的分析可知,如果你不在web.xml中定义webAppRootKey参数,那么你就得把 log4j.appender.logfile.File=${petclinic.root}/WEB-INF/petclinic.log中的petclinic.root变量改为webapp.root变量或者干脆换成别的绝对路径了。
发表评论
-
tomcat,EOFException解决
2012-05-22 16:06 884读写session出错,EOFException 清空 ... -
httpcomponent,httpclient
2012-05-03 11:11 835CookieStore cookieStore = new B ... -
防SQL注入
2012-04-18 16:24 760StringEscapeUtils.escapeSql(val ... -
tomcat6.0 SSI配置
2011-08-29 19:15 697http://blog.csdn.net/samgu3663/ ... -
tomcat 主项目配置
2011-08-05 15:49 723<?xml version='1.0' encoding ... -
tomcat 环境变量配置
2011-07-20 10:57 767http://blog.pfan.cn/suneveryday ... -
tomcat javamail 缺少jar包
2011-07-10 17:34 751在做javamail的时候需要注意,tomcat的某些版本缺少 ... -
TOMCAT 部署问题解决方案
2011-02-24 10:01 770org.apache.jasper.Jas ... -
tomcat 虚拟主机配置方法
2010-10-18 13:16 861首先给操作系统配置虚拟主机,配置文件路径默认在C:\WINDO ... -
Apache log4j配置详解
2010-07-21 15:31 914http://wolfsquare.iteye.com/blo ... -
Apache Log4j配置
2010-07-20 16:59 752#log4j.rootLogger=debug,stdout ... -
Tomcat 虚拟目录
2010-07-20 11:07 722转自:http://soly84.blog.51cto.com ... -
TOMCAT5.5与JDK1.4兼容
2010-02-26 17:13 842只要下载apache-tomcat-5.5.12-compat ... -
WebService,axis-1_4的安装
2010-02-06 13:56 1091set AXIS_HOME=E:\Apache\WebServ ... -
WebService
2010-02-03 16:23 614java -lhttp http://topic.csdn. ...
相关推荐
Apache Log4j 2 (apache-log4j-2.17.1-bin.zip)是对 Log4j 的升级,它比其前身 Log4j 1.x 提供了重大改进,并提供了 Logback 中可用的许多改进,同时修复了 Logback 架构中的一些固有问题。修复了安全漏洞 CVE-...
Apache Log4j2 远程代码执行漏洞检测工具,包含windows版和linux版。图形化 Apache Log4j2检测工具
Apache Log4j2紧急缓解措施
Apache Log4j_1.2.17 完整依赖包,在jdk1.8.201中测试通过。使用教程https://www.tutorialspoint.com/springmvc/springmvc_log4j.htm
Pro Apache Log4j second edition Pro Apache Log4j second edition Pro Apache Log4j second edition Pro Apache Log4j second edition Pro Apache Log4j second edition
Apache Log4j 2存在远程代码执行漏洞处置指南 及期检测工具
解决Apache Log4j 远程代码执行漏洞log4j2部分jar,包含log4j-1.2-api-2.15.0.jar,log4j-api-2.15.0.jar,log4j-core-2.15.0.jar,log4j-to-slf4j-2.15.0.jar
apache log4j使用大全 log4j使用
apache log4j 日志系统实现原理.doc,Apache Log4j 学习笔记 Apache Logging Project Homepage: http://logging.apache.org
Apache Log4j 2.0 发布第 4 个 Beta 版本,包括的新特性有: o Added Log4j 2 to SLF4J adapter. o LOG4J2-131: Add SMTPAppender. Thanks to Scott Severtson. o Added hostName and contextName to property ...
Apache Log4j 2 (apache-log4j-2.17.1-bin.tar.gz)是对 Log4j 的升级,它比其前身 Log4j 1.x 提供了重大改进,并提供了 Logback 中可用的许多改进,同时修复了 Logback 架构中的一些固有问题。修复了安全漏洞 CVE-...
Apache Log4j 2 源代码( apache-log4j-2.17.1-src.tar.gz) 是对 Log4j 的升级,它比其前身 Log4j 1.x 提供了重大改进,并提供了 Logback 中可用的许多改进,同时修复了 Logback 架构中的一些固有问题。修复了安全...
Pro Apache Log4j Second Edition
ApacheLog4j漏洞验证工具
Apache Log4j 2 源代码( apache-log4j-2.17.1-src.zip) 是对 Log4j 的升级,它比其前身 Log4j 1.x 提供了重大改进,并提供了 Logback 中可用的许多改进,同时修复了 Logback 架构中的一些固有问题。修复了安全漏洞...
Java 6 将 log4j 升级到 2.3.2 版本,Java 7 将 log4j 升级到 2.12.4 版本,Java 8 或更高版本将 log4j 升级到 2.17.1 版本
apache log4j-2.15.0-rc2 编译后 jar 文件 应对 Apache Log4j2远程代码执行漏洞 jar文件在每个组件下的 target 文件夹中 jar文件在每个组件下的 target 文件夹中 jar文件在每个组件下的 target 文件夹中
但Apache软体基金会又释出了Log4j 2.17.0版来修补新的阻断服务(Denial of Service,DoS)漏洞。Log4j 团队已获悉一个安全漏洞 CVE-2021-45105,该漏洞已在 Java 8 及更高版本的 Log4j 2.17.0 中得到解决。
apache-log4j-2.17.0-bin.tar.gz
4. Log4j 1.x Migration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 5. API . . . . . . . . . . . . . . . . . . . . . . . . . . . ....