how to log exception from a struts action class
Hi guys,
I am recoding my application to use the strut framework. There's one small thing i wonder is that how i can log an exception arrise in an action class. In my original servlet, wherever an exception arise, i use:
catch(Exception e)
{
getServletContext().log("User enter an invalid date");
throw e;
}
However, when i move this servlet into a action class, the getServletContext method doesnt work anymore. I thought action is a child of httpServlet but since getServletContext is not available in action, then how can i log the error?
Hope to get some help
Message was edited by:
lnthai2002
# 1
> Hi guys,
> I am recoding my application to use the strut
> framework. There's one small thing i wonder is that
> how i can log an exception arrise in an action class.
> In my original servlet, wherever an exception arise,
> i use:
> > catch(Exception e)
> {
> getServletContext().log("User enter an invalid
> valid date");
>throw e;
> }
>
> However, when i move this servlet into a action
> class, the getServletContext method doesnt work
> anymore. I thought action is a child of httpServlet
> but since getServletContext is not available in
> action, then how can i log the error?
> Hope to get some help
>
> Message was edited by:
> lnthai2002
Action class is just a POJO and works a handler of your request. ActionServlet invoke your Action class based on the action you call in your URL. When you are usign the Struts why do you need your Original Servel, use the ActionServlet and if required you can extend it and create your own servlet
# 2
Hi,
I submit some sites, Reg logging
you just try this
http://logging.apache.org/log4j/docs/api-1.3/org/apache/log4j/HTMLLayout.html#method_summary
http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/log4j.html
http://www.zanthan.com/itymbi/archives/000789.html
for download and steps
http://minaret.biz/tips/log4j.html