The problem of configuring webAppRootKey with log4j and web.xml

When deploying two or more projects under tomcat, it is best to define the webAppRootKey parameter in the web.xml file. If not defined, it will default to "webapp.root", as follows:
<!-- application path-->  
    <context-param>  
        <param-name>webAppRootKey</param-name>  
        <param-value>webapp.root</param-value>  
    </context-param>

It is best to have different parameter values ​​for each item of the newspaper, so as not to cause item conflicts
严重: 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!

For multiple projects, the webAppRootKey needs to be configured. The main purpose here is to allow the log to write the log to the root directory of the corresponding project. For example, if I configure the webAppRootKey of these two projects as
<!-- application path-->  
    <context-param>  
        <param-name>webAppRootKey</param-name>  
        <param-value>webapp.root1</param-value>  
    </context-param>

<!-- application path-->  
    <context-param>  
        <param-name>webAppRootKey</param-name>  
        <param-value>webapp.root2</param-value>  
    </context-param>

This way there will be no conflicts.

After the definition, the absolute path of ROOT will be written to the system variable when the Web Container starts. Then in the log4j configuration file, ${webName.root } can be used to represent the absolute path of the Web directory, and the log file can be stored in the webapp.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327018472&siteId=291194637