LOG4J is an Apache open source project, through the use of log4j, we can control the log information delivery destination is the console, files, GUI components, even the socket server, NT Event recorder, UNIX syslog daemon, etc. We can also control the output format of each log, and by defining the level of each log information, we can control the log generation process more carefully. Most interesting of all, these can be configured flexibly with a single configuration file, without the need to modify the code of the application.
In fact, I think he is a component that can monitor our web application, so that we can see how our program is running and the related records after the error.
I reported a mistake when I was using it.
Java code
- Severity: Exception sending context initialized event to listener instance of class Org.springframework.web.util.Log4jConfi Glistener
- Java.lang.IllegalStateException:Web App root system property already set to different value: ' webapp.root ' = [D:\MyEc Lipseproject\.metadata\.me_tcat\webapps\reservationsystem\] instead of [D:\MyEclipseProject\.metadata\.me_tcat\ Webapps\springmvcdemo\]-Choose unique values for the ' Webapprootkey ' Context-param in your web. XML files!
Let's take a look at the configuration of log4j:
Java code
- Log4j.rootlogger=info, stdout, logfile
- Log4j.appender.stdout=org.apache.log4j.consoleappender
- Log4j.appender.stdout.layout=org.apache.log4j.htmllayout
- #log4j. appender.stdout.layout.conversionpattern=%d%p [%c]-%m%n
- log4j.appender.stdout.layout.conversionpattern=-%m%n
- Log4j.appender.logfile=org.apache.log4j.rollingfileappender
- Log4j.appender.logfile.file=${webapp.root}/webapp.html
- log4j.appender.logfile.maxfilesize=512kb
- # Keep three backup files.
- log4j.appender.logfile.maxbackupindex=3
- # Pattern to Output:date Priority [Category]-message
- Log4j.appender.logfile.layout=org.apache.log4j.htmllayout
- log4j.appender.logfile.layout.conversionpattern=%d%p [%c]-%m%n
- Log4j.logger.com.opensymphony.xwork2=error
- # Control Logging for other open source packages
- Log4j.logger.org.springframework=error
- Log4j.logger.org.quartz=error
- Log4j.logger.net.sf.ehcache=error
- Log4j.logger.net.sf.navigator=error
- Log4j.logger.org.apache.commons=error
- Log4j.logger.org.apache.struts=error
- Log4j.logger.org.hibernate=debug
- # Struts Ognlutil issues unimportant warnings
- Log4j.logger.com.opensymphony.xwork2.util.ognlutil=error
- Log4j.logger.com.opensymphony.xwork2.ognl.ognlvaluestack=error
Found that there is no problem ah, but, please note ${webapp.root} This variable, with the error hint about a glance, meaning that the Web application root system properties have been set, it is said that the "Webapp.root" This configuration name has been used, no longer use this ,
It also prompts choose unique values for the ' Webapprootkey ' Context-param in your. xml files, which means that we can configure a unique ' Webappro ' in Web. xml Otkey ', so there will be no conflict.
This problem can occur when a Web server deploys multiple applications that use LOG4J, and if configured improperly, this error can really make you depressed and crazy. That's the problem. A Tomcat deploys 2 projects that use log4j.
Then I fix it: press the hint in Web. XML to add
Java code
- <context-param>
- <param-name>webAppRootKey</param-name>
- <param-value>myapp.root</param-value>
- </context-param>
Then write ${myapp.root} in the Log4j.properties, as long as the name is not duplicated, it will not produce the Web App root system property already set to different value error. While it is relatively rare to deploy multiple applications on a single server when it is used formally, it is still safe to use, but also to standardize our program-related nomenclature,
${webapp.root} is a good habit to change to ${[application].root}.
Java.lang.IllegalStateException:Web App root system property already set to different value error reason and resolution LOG4J