2

I want to configure a parameter for the exception interceptor to log exceptions. So I created a package in struts.xml and copied the default-stack from struts-default.xml. However it doesn't log exceptions and seems to still use the defaultStack.

Here is my struts.xml:

<struts>
   <package name="default" extends="struts-default">
      <interceptors>
         <interceptor-stack name="myStack">
            <interceptor-ref name="exception">
               <param name="logEnabled"> true </param>
               <param name="logCategory"> struts </param>
               <param name="logLevel"> ERROR </param>
            </interceptor-ref>
            ...
         </interceptor-stack>
      </interceptors>

      <default-interceptor-ref name="myStack" />
   </package>
</struts>
Roman C
  • 49,761
  • 33
  • 66
  • 176
user1
  • 21
  • 1
  • 2
  • 1
    Please space all xml in by at least 4 spaces and it will show up. – Quaternion Jan 24 '11 at 05:50
  • Please fill in the ... and also add an action which is supposed to make use of this stack. – Quaternion Jan 24 '11 at 18:14
  • 1
    I copied the XML snippet above into my own webapp, and filled in the rest of the default stack from the default struts xml file, and it worked fine. There must be something else going on in your project that would prevent the logging from occurring. Providing the entire struts.xml file you are using would help to solve your issue. – Dustin Wilhelmi Jan 25 '11 at 15:59

1 Answers1

1

This should work fine, provided all the new actions that you add are in the same package, i.e, "default" package which extends struts-default.

AFAIK there can be just 1 possibility because of which it can go wrong, and that will be : You have written your actions in a different package(that again extends struts-default rather than "default"-the custom package), and thus, it would use the defaultStack as the default interceptor stack, which is the default stack for struts-default.

So, if you want the default stack to be over-ridden by myStack, make sure that your action is inside your custom package - "default" or inside a package that extends your custom package "default" rather than the struts-default package.

Sachin Midha
  • 1,068
  • 2
  • 8
  • 11