In addition to configuring log4j to use a FileAppender to write logs to
a file, here's a very simple way to log exceptions manually from the
exception page:
Within your jsp include the following code:
<s:set name="stackTrace" value="%{exceptionStack}" scope="page"/>
<%
String stackTrace = (String)
pageContext.getAttribute("stackTrace");
new ExceptionLogger().logException(stackTrace);
%>
where ExceptionLogger is a class you write to log the stackStrace or
other information to a file.
I use a similar fragment in the JSP to email a copy of the stacktrace to
the administrator if the exception page is ever displayed.
Hope that helps,
Jeromy Evans
Richard Sayre wrote:
I am trying to log the exception that get cought by the struts
exception handler.
So far I have .jsp page that shows the exception:
An Exception Has occured!
<br/><br/>
<s:property value="%{exception}"/>
<br/><br/>
=====================================
<s:property value="%{exceptionStack }"/>
I am going to change this page to display a generic error message. I
want to write the value of exception and exceptionStack to a file.
How can I do this? I can't figure out a way to write those values to
a file on the JSP page.
I tried to pass the values it to an Action but I couldn't pass in the
exceptionStack. exception and exceptionStack are both Strings in my
Action class.
<result name="Exception" type="redirect-action">
<param name="actionName">/SystemError</param>
<param name="parse">true</param>
<param name="exception">${exception}</param>
<param name="exceptionStack">${exceptionStack}</param>
</result>
When an exception occues the result does not get executed and I get
the following Stack Trace. I truncated most of the trace.
java.lang.ArrayIndexOutOfBoundsException: 8192
at
org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:720)
at
org.apache.coyote.http11.InternalOutputBuffer.write(InternalOutputBuffer.java:627)
at
org.apache.coyote.http11.InternalOutputBuffer.sendHeader(InternalOutputBuffer.java:500)
at
org.apache.coyote.http11.Http11Processor.prepareResponse(Http11Processor.java:1615)
at
org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:962)
at org.apache.coyote.Response.action(Response.java:182)
at org.apache.coyote.Response.sendHeaders(Response.java:378)
at
org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:317)
at
org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:278)
at
org.apache.catalina.connector.Response.finishResponse(Response.java:476)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:619)
Any suggestion on where I am going wrong would be appreciated.
Thanks
Rich
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]