My team did something like this recently.  We put a line in our
*.application file:

<page name="Exception" specification-path="/ErrorPage.page" />

Then we copied/modified the code from tapestry's error page so we could pipe
tapestry's stacktrace generation to log4j.  The actual html/page file was
just our friendly message and layout with the original tapestry
implementation sitting in a hidden div to make life easy for developers.
Here's our code:

public abstract class ErrorPage extends BasePage {
        
        @InjectObject("service:tapestry.globals.HttpServletResponse")
        public abstract HttpServletResponse getResponse();
        
        private static final Logger log =
Logger.getLogger("com.vms.adsite.pages.ErrorPage");     

    public abstract void setExceptions(ExceptionDescription[] exceptions);

    public void setException(Throwable value) {
        ExceptionAnalyzer analyzer = new ExceptionAnalyzer();
        ExceptionDescription[] exceptions = analyzer.analyze(value);
        setExceptions(exceptions);
        String text = "";
        for (ExceptionDescription exception : exceptions) {
                text += "Class: " + exception.getExceptionClassName() +
"\n";
                text += "Message: " + exception.getMessage() + "\n";
                for (ExceptionProperty property : exception.getProperties())
{
                        text += "Property: " + property.getName() + " = " +
property.getValue() + "\n";
                }
        }
        String[] stack = exceptions[exceptions.length-1].getStackTrace();
        for (String stackItem : stack) {
                text += stackItem + "\n";
        }
                log.error(text);
    }
}       
        

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 21, 2006 6:43 AM
To: tapestry-user@jakarta.apache.org
Subject: Logging error page into log4j

Hi all,

How do get the default error page to log into log4j? 

I really dont need to overide the default error page (this is an internal
application) but I do need the errors logged. Any help is appreciated!

Thanks,
Amir



---------------------------------------------------------------------
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]

Reply via email to