在tomcat下部署兩個(gè)或多個(gè)項(xiàng)目時(shí),web.xml文件中最好定義webAppRootKey參數(shù),如果不定義,將會(huì)缺省為“webapp.root”,如下:
<!-- 應(yīng)用路徑 -->
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapp.root</param-value>
</context-param>
最好報(bào)紙每個(gè)項(xiàng)目的參數(shù)值不同,以免引起項(xiàng)目沖突
嚴(yán)重: Exception sending context initialized event to listener instance of class
org.springframework.web.util.Log4jConfigListener
[Java](http://lib.csdn.net/base/javaee).lang.IllegalStateException: Web app root system property already set to different value: 'webapp.root' = [C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\webapps\DRMProject\] instead of [C:\Program Files (x86)\Apache Software Foundation\Tomcat 6.0\webapps\DRMSn\] - Choose unique values for the 'webAppRootKey' context-param in your web.xml files!
對(duì)多個(gè)項(xiàng)目要對(duì)webAppRootKey進(jìn)行配置,這里主要是讓log能將日志寫到對(duì)應(yīng)項(xiàng)目根目錄下,如我配置這兩個(gè)項(xiàng)目的webAppRootKey為
<!-- 應(yīng)用路徑 -->
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapp.root1</param-value>
</context-param>
<!-- 應(yīng)用路徑 -->
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>webapp.root2</param-value>
</context-param>
這樣就不會(huì)出現(xiàn)沖突了。
定義以后,在Web Container啟動(dòng)時(shí)將把ROOT的絕對(duì)路徑寫到系統(tǒng)變量里。然后log4j的配置文件里就可以用${webName.root }來表示W(wǎng)eb目錄的絕對(duì)路徑,把log文件存放于webapp中。