LOG4J,SLF4J日志,web.xml中webAppRootKey
来源:互联网 发布:asp.net 数据显示控件 编辑:程序博客网 时间:2024/05/20 19:45
转自:http://elf8848.iteye.com/blog/1504222
日志解决方案
------------------------------------------------------------------------------------------------
一、org.apache.commons.logging.Log方案
二、slf4j方案
参见:
java日志,需要知道的几件事(commons-logging,log4j,slf4j,logback)
http://www.iteye.com/topic/934593
log4j logback slf4j项目配置中的简单总结
http://www.iteye.com/topic/345924
Log4J diy手册
http://blog.csdn.net/cuker919/article/details/5708775
web.xml中webAppRootKey
------------------------------------------------------------------------------------------------
1、 web.xml配置
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapp.root</param-value>
</context-param>
"webapp.root"这个字符串可以随便写任何字符串。如果不配置默认值是"webapp.root"。
可以用System.getProperty("webapp.root")来动态获项目的运行路径。
一般返回结果例如:/usr/local/tomcat6/webapps/项目名
2、解决以下报错
部署在同一容器中的Web项目,要配置不同的<param-value>,不能重复,否则报类似下面的错误:
Web app root system property already set to different value: 'webapp.root' = [/home/user/tomcat/webapps/project1/] instead of [/home/user/tomcat/webapps/project2/] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
意思是“webapp.root”这个key已经指向了项目1,不可以再指向项目2.
3、加载方式
Spring通过org.springframework.web.util.WebAppRootListener 这个监听器来运行时的项目路径。
但是如果在web.xml中已经配置了 org.springframework.web.util.Log4jConfigListener这个监听器,
则不需要配置WebAppRootListener了。因为Log4jConfigListener已经包含了WebAppRootListener的功能
一般配置类型下面的例子:
- <!-- 加载Log4J 配置文件 -->
- <context-param>
- <param-name>log4jConfigLocation</param-name>
- <param-value>WEB-INF/conf/log4j.properties</param-value>
- </context-param>
- <context-param>
- <param-name>log4jRefreshInterval</param-name>
- <param-value>3000</param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
- </listener>
4、在运行时动态的找出项目的路径
在log4j.properties配置文件,就可以按下面的方式使用${webapp.root}:
log4j.appender.file.File=${webapp.root}/WEB-INF/logs/sample.log
就可以在运行时动态的找出项目的路径
- LOG4J,SLF4J日志,web.xml中webAppRootKey
- log4j slf4j 以及web.xml日志配置
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- web.xml中webAppRootKey
- IIS修改上传附件大小后无法启动,错误代码-2145318902的解决方式
- codeforces 261B
- JSP的内置对象(application)
- 学习ASP编程必会的代码
- javaweb入门(5)-- 详细了解http协议3
- LOG4J,SLF4J日志,web.xml中webAppRootKey
- 制造魔方
- 第二个项目的总结 序号生成工具工具(历时3天)
- 用getstring提高ASP运行速度
- SGU223 -状态压缩DP
- 【网络挖掘:成就与未来方向】之网络挖掘应用程序与相关概念
- 83个Photoshop技巧
- win7编译的QT4.8.4的mysql驱动
- 中文域名好不好?有什么价值?