When you configure multiple instances in Tomcat, you cannot use the default Webapprootkey, you need to explicitly configure the Webapprootkey value in Web. XML, otherwise you will get an error at startup, as shown below
Severity: exception sending context initialized event to listener instance of class ch.qos.logback.ext.spring.web.logbackconfiglistenerjava.lang.illegalstateexception: web app root system property already set to different value : ' Webapp.root ' = [c:\apache-tomcat-8.0.32\webapps\weblearn\] instead of [c:\ apache-tomcat-8.0.32\webapps\weblearn3\] - choose unique values for the ' Webapprootkey ' context-param in your web.xml files!at Org.springframework.web.util.WebUtils.setWebAppRootSystemProperty (webutils.java:162) at Ch.qos.logback.ext.spring.web.WebLogbackConfigurer.initLogging (Unknown source) at Ch.qos.logback.ext.spring.web.LogbackConfigListener.contextInitialized (Unknown source) at Org.apache.catalina.core.StandardContext.listenerStart (standardcontext.java:4812) at org.Apache.catalina.core.StandardContext.startInternal (standardcontext.java:5255) at Org.apache.catalina.util.LifecycleBase.start (lifecyclebase.java:147) at Org.apache.catalina.core.ContainerBase.addChildInternal (containerbase.java:725) at Org.apache.catalina.core.ContainerBase.addChild (containerbase.java:701) at Org.apache.catalina.core.StandardHost.addChild (standardhost.java:717) at Org.apache.catalina.startup.HostConfig.deployDescriptor (hostconfig.java:585) at Org.apache.catalina.startup.hostconfig$deploydescriptor.run (hostconfig.java:1794) at Java.util.concurrent.executors$runnableadapter.call (executors.java:511) at Java.util.concurrent.FutureTask.run (futuretask.java:266) at Java.util.concurrent.ThreadPoolExecutor.runWorker (threadpoolexecutor.java:1142) at Java.util.concurrent.threadpoolexecutor$worker.run (threadpoolexecutor.java:617) At java.lang.Thread.run ( thread.java:745)
Therefore, Webapprootkey is configured in Web. XML, because the configuration of Logback was previously configured, so the configuration of Webapprootkey is put together with the Logback configuration, as shown below.
<context-param><param-name>logbackconfiglocation</param-name><param-value>/web-inf/ Config/logback3.xml</param-value><param-name>webapprootkey</param-name><param-value> Weblearn3.root</param-value></context-param>
Restart the server found no above error, but the server log is not generated to the file, so Judge Context-param can only put a pair of param-name and Param-value, and finally modified as follows
<context-param><param-name>webapprootkey</param-name><param-value>weblearn3.root</ param-value></context-param><context-param><param-name>logbackconfiglocation</ Param-name><param-value>/web-inf/config/logback3.xml</param-value></context-param>
Problem solving
This article from "Dream do not know is a guest" blog, reproduced please contact the author!
Web. XML <context-param> can only place a pair of <param-name> and <param-value>