最近用struts2发现后台总是出现各种警告,于是开始解决 warning
九月 23, 2016 9:55:30 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [struts.actionMapping]九月 23, 2016 9:55:30 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [org.apache.catalina.jsp_file]
九月 23, 2016 9:55:40 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [struts.actionMapping]
九月 23, 2016 9:55:40 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [struts.valueStack]
九月 23, 2016 9:55:41 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [org.apache.catalina.jsp_file]
九月 23, 2016 9:55:42 下午 org.apache.jasper.compiler.TldLocationsCache tldScanJar
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
九月 23, 2016 9:55:46 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [templateDir]
九月 23, 2016 9:55:46 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [templateDir]
九月 23, 2016 9:55:46 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [theme]
九月 23, 2016 9:55:46 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [theme]
九月 23, 2016 9:55:46 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [templateDir]
九月 23, 2016 9:55:46 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [templateDir]
九月 23, 2016 9:55:46 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [theme]
九月 23, 2016 9:55:46 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [theme]
九月 23, 2016 9:55:48 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [.freemarker.Request]
九月 23, 2016 9:55:48 下午 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find property [.freemarker.RequestParameters]
于是找了好多资料才发现:
Missing Properties
This message states that the framework searched for a property in the value stack and failed to find it.
2008-04-19 14:21:08,177 WARN [http-8443-Processor25] [OgnlValueStack] Could not find property [templateDir] 2008-04-19 14:21:08,177 WARN [http-8443-Processor25] [OgnlValueStack] Could not find property [templateDir] 2008-04-19 14:21:08,177 WARN [http-8443-Processor25] [OgnlValueStack] Could not find property [templateDir] 2008-04-19 14:21:08,178 WARN [http-8443-Processor25] [OgnlValueStack] Could not find property [org.apache.catalina.jsp_file]
To hide these messages, turn off the WARN level logging for OgnlValueStack.
eg. Include a new limit category in your log4j.xml file (only log errors or worse):
<span style="color:#000000;"><span class="code-tag"><category name=<span class="code-quote">"com.opensymphony.xwork2.ognl.OgnlValueStack"</span>></span> <span class="code-tag"><priority value=<span class="code-quote">"error"</span>/></span> <span class="code-tag"></category></span></span>
<span style="color:#000000;"><span class="code-tag">原来是少了log4j配置文件,顿悟+无语。。。。。</span></span>
<span style="color:#000000;"><span class="code-tag">看一下lib包,果然没有log4</span></span><span style="color:#000000;"><span class="code-tag">j-xxx.jar,到apache下个log4j-1.2.9.jar包放到lib下。</span></span>
<span style="color:#000000;"><span class="code-tag">现在不需要写log4.xml也不会出现警告信息。</span></span>
<span style="color:#000000;"><span class="code-tag">如果加上去也可以,把日志信息的级别调整为ERRORJ即可。</span></span>
<span style="color:#000000;"><span class="code-tag">若水用的是log4j.properties文件并没有用log4j.xml</span></span>(个人习惯而已),考虑到有些朋友对log4j不太熟悉
<span class="code-tag">贴一下代码</span>log4j.properties 放在src目录下就好了,记得在系统盘上建立 log4j.appender.logfile.File对应的文件。
<span class="code-tag"># For JBoss: Avoid to setup log4j outside $JBOSS_HOME/server/default/deploy/log4j.xml # For all other servers: Comment out the Log4J listener in web.xml too log4j.rootLogger=ERROR, console, logfile</span>
<span class="code-tag">#console log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout log4j.appender.console.layout.ConversionPattern=%d %p [%c] - <%m>%n #log4j.appender.console.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n</span>
<span class="code-tag">#logfile log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender log4j.appender.logfile.File=C:/ask/logs/ask.log</span>
<span class="code-tag"># Log4j Max File Size # log4j.appender.logfile.MaxFileSize=10MB # Log4j BackUp File Index # log4j.appender.logfile.MaxBackupIndex=10</span>
<span class="code-tag">log4j.appender.logfile.layout=org.apache.log4j.PatternLayout # Pattern to output: date priority [category] - <message>line_separator log4j.appender.logfile.layout.ConversionPattern=%d %p [%c] - <%m>%n</span>
<span class="code-tag">#log4j.logger.org.hibernate=info #log4j.logger.org.hibernate=debug ### log HQL query parser activity #log4j.logger.org.hibernate.hql.ast.AST=debug ### log just the SQL #log4j.logger.org.hibernate.SQL=info ### log JDBC bind parameters ### #log4j.logger.org.hibernate.type=info #log4j.logger.org.hibernate.type=debug ### log schema export/update ### #log4j.logger.org.hibernate.tool.hbm2ddl=debug ### log HQL parse trees #log4j.logger.org.hibernate.hql=info ### log cache activity ### #log4j.logger.org.hibernate.cache=debug ### log transaction activity #log4j.logger.org.hibernate.transaction=debug ### log JDBC resource acquisition #log4j.logger.org.hibernate.jdbc=debug ### enable the following line if you want to track down connection ### </span>
#log4j.logger.org.hibernate.connection.DriverManagerConnectionProvider=trace