You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by DavidZaz <dz...@cait.org> on 2010/02/04 22:14:59 UTC

Problem with Exception Interceptor

I have an exception interceptor declared in my struts.xml, but no log
messages ever appear in the log category that I specified. In my struts.xml,
I have the following:

<package name="default" extends="struts-default">
   <interceptor-stack name="defaultStack">
      <interceptor-ref name="exception">
            true
            error.unhandled
            WARN
      </interceptor-ref>
   </interceptor-stack>
</package>

In my log4j.xml file, I have the following logger configured:

<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
    <layout class="org.apache.log4j.PatternLayout">
        
    </layout>
</appender>
<logger name="error.unhandled">
    <level value="DEBUG"/>
    <appender-ref ref="CONSOLE" />
</logger>

When I run my application and throw an unhandled exception, the log4j logger
does not print the exception to my appender. As a test, I wrote the
following code into one of my actions:

org.apache.log4j.Logger myLogger =
org.apache.log4j.Logger.getLogger("error.unhandled");
myLogger.warn("Test Message");

The "Test Message" did appear in my log, but I don't understand why struts
will not provide the same behavior through its exception interceptor.

Does anyone have any ideas about what I am doing wrong?
-- 
View this message in context: http://old.nabble.com/Problem-with-Exception-Interceptor-tp27459864p27459864.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with Exception Interceptor

Posted by Cimballi <ci...@gmail.com>.
Hum, it's strange because in fact at fatal level you should only have
fatal log messages...


On Thu, Feb 4, 2010 at 5:33 PM, DavidZaz <dz...@cait.org> wrote:
>
> As an update, I changed the level in my struts.xml to FATAL and the logging
> started working. This behavior confuses me since I don't have any loggers
> set higher than DEBUG/INFO in my log4j.xml file. However, this does lead me
> to believe that log4j and not struts is the problem.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with Exception Interceptor

Posted by DavidZaz <dz...@cait.org>.
As an update, I changed the level in my struts.xml to FATAL and the logging
started working. This behavior confuses me since I don't have any loggers
set higher than DEBUG/INFO in my log4j.xml file. However, this does lead me
to believe that log4j and not struts is the problem.


Cimballi-2 wrote:
> 
> :D Ok, I just noticed than the mailing list engine, or maybe google,
> removes the < param > tag...
> 
> Cimballi
> 
> 
> On Thu, Feb 4, 2010 at 4:40 PM, DavidZaz <dz...@cait.org> wrote:
>>
>> I actually had the interceptor-ref configured like that in my source
>> code. It
>> looks like my code didn't paste from eclipse very well. Sorry about that.
>>
>> Does the logCategory need to start with com.packageName? Can it start
>> with
>> error or org or something else?
>>
>>
>> Cimballi-2 wrote:
>>>
>>> You interceptor declaration should be like that :
>>>         <interceptor-ref name="exception">
>>>           true
>>>           com.xxx
>>>           ERROR
>>>         </interceptor-ref>
>>>
>>> Cimballi
>>>
>>>
>>> On Thu, Feb 4, 2010 at 4:14 PM, DavidZaz <dz...@cait.org> wrote:
>>>>
>>>> I have an exception interceptor declared in my struts.xml, but no log
>>>> messages ever appear in the log category that I specified. In my
>>>> struts.xml,
>>>> I have the following:
>>>>
>>>> <package name="default" extends="struts-default">
>>>>   <interceptor-stack name="defaultStack">
>>>>      <interceptor-ref name="exception">
>>>>            true
>>>>            error.unhandled
>>>>            WARN
>>>>      </interceptor-ref>
>>>>   </interceptor-stack>
>>>> </package>
>>>>
>>>> In my log4j.xml file, I have the following logger configured:
>>>>
>>>> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
>>>>    <layout class="org.apache.log4j.PatternLayout">
>>>>
>>>>    </layout>
>>>> </appender>
>>>> <logger name="error.unhandled">
>>>>    <level value="DEBUG"/>
>>>>    <appender-ref ref="CONSOLE" />
>>>> </logger>
>>>>
>>>> When I run my application and throw an unhandled exception, the log4j
>>>> logger
>>>> does not print the exception to my appender. As a test, I wrote the
>>>> following code into one of my actions:
>>>>
>>>> org.apache.log4j.Logger myLogger =
>>>> org.apache.log4j.Logger.getLogger("error.unhandled");
>>>> myLogger.warn("Test Message");
>>>>
>>>> The "Test Message" did appear in my log, but I don't understand why
>>>> struts
>>>> will not provide the same behavior through its exception interceptor.
>>>>
>>>> Does anyone have any ideas about what I am doing wrong?
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/Problem-with-Exception-Interceptor-tp27459864p27459864.html
>>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Problem-with-Exception-Interceptor-tp27459864p27460190.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Problem-with-Exception-Interceptor-tp27459864p27460842.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with Exception Interceptor

Posted by Greg Lindholm <gr...@gmail.com>.
It's Nabble that removes the < param > tags

On Thu, Feb 4, 2010 at 5:10 PM, Cimballi <ci...@gmail.com> wrote:
> :D Ok, I just noticed than the mailing list engine, or maybe google,
> removes the < param > tag...
>
> Cimballi
>

>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with Exception Interceptor

Posted by Cimballi <ci...@gmail.com>.
:D Ok, I just noticed than the mailing list engine, or maybe google,
removes the < param > tag...

Cimballi


On Thu, Feb 4, 2010 at 4:40 PM, DavidZaz <dz...@cait.org> wrote:
>
> I actually had the interceptor-ref configured like that in my source code. It
> looks like my code didn't paste from eclipse very well. Sorry about that.
>
> Does the logCategory need to start with com.packageName? Can it start with
> error or org or something else?
>
>
> Cimballi-2 wrote:
>>
>> You interceptor declaration should be like that :
>>         <interceptor-ref name="exception">
>>           true
>>           com.xxx
>>           ERROR
>>         </interceptor-ref>
>>
>> Cimballi
>>
>>
>> On Thu, Feb 4, 2010 at 4:14 PM, DavidZaz <dz...@cait.org> wrote:
>>>
>>> I have an exception interceptor declared in my struts.xml, but no log
>>> messages ever appear in the log category that I specified. In my
>>> struts.xml,
>>> I have the following:
>>>
>>> <package name="default" extends="struts-default">
>>>   <interceptor-stack name="defaultStack">
>>>      <interceptor-ref name="exception">
>>>            true
>>>            error.unhandled
>>>            WARN
>>>      </interceptor-ref>
>>>   </interceptor-stack>
>>> </package>
>>>
>>> In my log4j.xml file, I have the following logger configured:
>>>
>>> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
>>>    <layout class="org.apache.log4j.PatternLayout">
>>>
>>>    </layout>
>>> </appender>
>>> <logger name="error.unhandled">
>>>    <level value="DEBUG"/>
>>>    <appender-ref ref="CONSOLE" />
>>> </logger>
>>>
>>> When I run my application and throw an unhandled exception, the log4j
>>> logger
>>> does not print the exception to my appender. As a test, I wrote the
>>> following code into one of my actions:
>>>
>>> org.apache.log4j.Logger myLogger =
>>> org.apache.log4j.Logger.getLogger("error.unhandled");
>>> myLogger.warn("Test Message");
>>>
>>> The "Test Message" did appear in my log, but I don't understand why
>>> struts
>>> will not provide the same behavior through its exception interceptor.
>>>
>>> Does anyone have any ideas about what I am doing wrong?
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Problem-with-Exception-Interceptor-tp27459864p27459864.html
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Problem-with-Exception-Interceptor-tp27459864p27460190.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with Exception Interceptor

Posted by DavidZaz <dz...@cait.org>.
I actually had the interceptor-ref configured like that in my source code. It
looks like my code didn't paste from eclipse very well. Sorry about that.

Does the logCategory need to start with com.packageName? Can it start with
error or org or something else?


Cimballi-2 wrote:
> 
> You interceptor declaration should be like that :
>         <interceptor-ref name="exception">
>           true
>           com.xxx
>           ERROR
>         </interceptor-ref>
> 
> Cimballi
> 
> 
> On Thu, Feb 4, 2010 at 4:14 PM, DavidZaz <dz...@cait.org> wrote:
>>
>> I have an exception interceptor declared in my struts.xml, but no log
>> messages ever appear in the log category that I specified. In my
>> struts.xml,
>> I have the following:
>>
>> <package name="default" extends="struts-default">
>>   <interceptor-stack name="defaultStack">
>>      <interceptor-ref name="exception">
>>            true
>>            error.unhandled
>>            WARN
>>      </interceptor-ref>
>>   </interceptor-stack>
>> </package>
>>
>> In my log4j.xml file, I have the following logger configured:
>>
>> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
>>    <layout class="org.apache.log4j.PatternLayout">
>>
>>    </layout>
>> </appender>
>> <logger name="error.unhandled">
>>    <level value="DEBUG"/>
>>    <appender-ref ref="CONSOLE" />
>> </logger>
>>
>> When I run my application and throw an unhandled exception, the log4j
>> logger
>> does not print the exception to my appender. As a test, I wrote the
>> following code into one of my actions:
>>
>> org.apache.log4j.Logger myLogger =
>> org.apache.log4j.Logger.getLogger("error.unhandled");
>> myLogger.warn("Test Message");
>>
>> The "Test Message" did appear in my log, but I don't understand why
>> struts
>> will not provide the same behavior through its exception interceptor.
>>
>> Does anyone have any ideas about what I am doing wrong?
>> --
>> View this message in context:
>> http://old.nabble.com/Problem-with-Exception-Interceptor-tp27459864p27459864.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Problem-with-Exception-Interceptor-tp27459864p27460190.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with Exception Interceptor

Posted by Cimballi <ci...@gmail.com>.
You interceptor declaration should be like that :
        <interceptor-ref name="exception">
          <param name="logEnabled">true</param>
          <param name="logCategory">com.xxx</param>
          <param name="logLevel">ERROR</param>
        </interceptor-ref>

Cimballi


On Thu, Feb 4, 2010 at 4:14 PM, DavidZaz <dz...@cait.org> wrote:
>
> I have an exception interceptor declared in my struts.xml, but no log
> messages ever appear in the log category that I specified. In my struts.xml,
> I have the following:
>
> <package name="default" extends="struts-default">
>   <interceptor-stack name="defaultStack">
>      <interceptor-ref name="exception">
>            true
>            error.unhandled
>            WARN
>      </interceptor-ref>
>   </interceptor-stack>
> </package>
>
> In my log4j.xml file, I have the following logger configured:
>
> <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
>    <layout class="org.apache.log4j.PatternLayout">
>
>    </layout>
> </appender>
> <logger name="error.unhandled">
>    <level value="DEBUG"/>
>    <appender-ref ref="CONSOLE" />
> </logger>
>
> When I run my application and throw an unhandled exception, the log4j logger
> does not print the exception to my appender. As a test, I wrote the
> following code into one of my actions:
>
> org.apache.log4j.Logger myLogger =
> org.apache.log4j.Logger.getLogger("error.unhandled");
> myLogger.warn("Test Message");
>
> The "Test Message" did appear in my log, but I don't understand why struts
> will not provide the same behavior through its exception interceptor.
>
> Does anyone have any ideas about what I am doing wrong?
> --
> View this message in context: http://old.nabble.com/Problem-with-Exception-Interceptor-tp27459864p27459864.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org