Search code examples
javaxmlstruts2warningsognl

Turning off OGNL warnings in Struts 2


I am trying to turn off the following warning message

OgnlValueStac W com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn Error setting expression 'checkboxidentifyer' with value '[Ljava.lang.String;@518b518b'

I have tried putting the following in my log4j.xml file

<logger name="log4j.logger.org.apache.struts2" >
    <level value="ERROR" />
    <appender-ref ref="console" />
</logger>
<logger name="log4j.logger.com.opensymphony" >
  <level value="ERROR" />
  <appender-ref ref="console" />
</logger>
<logger name="ognl.OgnlException" >
  <level value="ERROR" />
     <appender-ref ref="console" />
</logger>
<logger name="com.opensymphony.xwork2.util.logging.commons.CommonsLogger" >
  <level value="ERROR" />
  <appender-ref ref="console" />
</logger>
<logger name="ognl.OgnlRuntime" >
  <level value="ERROR" />
  <appender-ref ref="console" />
</logger>

I have also tried adding

<constant name="struts.devMode" value="false" />

to my struts.xml file. Also I have tried adding the following to the interceptor-stack section of the struts.xml file

<interceptor-ref name="defaultStack">
    <param name="excludeParams">.*?checkbox.*</param>
</interceptor-ref>

My questions are:

  1. Did I do a miss configuration?
  2. How do you disable the warnings.

Solution

  • The excludeParams is a property of the params interceptor and should be referenced like this

    <interceptor-ref name="defaultStack">
        <param name="params.excludeParams">.*?checkbox.*</param>
    </interceptor-ref>
    

    Note, if you use interceptor-ref tag on the action then it overrides the default interceptor stack and applicable only to this action config. For common usage consider creating a custom interceptor stack and make it default for any action configuration.

    You can set a logging level for interceptors and OGNL. Using log4j.properties

    log4j.logger.com.opensymphony.xwork2.interceptor=ERROR
    log4j.logger.com.opensymphony.xwork2.ognl=ERROR