You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by am...@yahoo.com on 2006/06/21 15:43:08 UTC

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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Logging error page into log4j

Posted by am...@yahoo.com.
Steve,

I did'nt need to create a specific error page, but thanks for the
ExceptionAnalyzer code snippet... that came pretty handy.

Thanks,
Amir


--- Steve Shucker <ss...@vmsinfo.com> wrote:

> 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: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com] 
> 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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Logging error page into log4j

Posted by Steve Shucker <ss...@vmsinfo.com>.
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: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com] 
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Logging error page into log4j

Posted by am...@yahoo.com.
That did the trick. Thanks!

--- James Carman <ja...@carmanconsulting.com> wrote:

> Copy the definition from the original hivemodule.xml:
> 
> <implementation service-id="tapestry.error.ExceptionPresenter">
> <invoke-factory>
>       <construct class="com.myco.web.error.MyExceptionPresenter">
>         <set-object property="exceptionPageName" 
>                        value="infrastructure:exceptionPageName"/>
>         <set-object property="requestExceptionReporter"
>                        value="infrastructure:requestExceptionReporter"/>
>         <set-object property="responseRenderer"
>                       value="infrastructure:responseRenderer"/>
>       </construct>
>     </invoke-factory>
> </implementation>
> -----Original Message-----
> From: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com] 
> Sent: Wednesday, June 21, 2006 10:46 AM
> To: James Carman; 'Tapestry users'
> Subject: RE: Logging error page into log4j
> 
> I wish it was that simple, but it's not working! The problem is that the
> _exceptionPageName field is not being set. When I removed the hivemodule.xml
> entry, the field gets populated with "Exception". So I tried this just to
> see
> if it works:
> 
> 	 @Override
> 	public void presentException(final IRequestCycle cycle, final
> Throwable cause)
> {
> 		 logger.error(cause);
> 		 setExceptionPageName("Exception");
> 		 super.presentException(cycle, cause);
> 	 }
> 
> I still get a blank page!
> 
> --- James Carman <ja...@carmanconsulting.com> wrote:
> 
> > Just extend ExceptionPresenterImpl and call your superclass'
> implementation!
> > :-)  Ain't object-oriented programming great?
> > 
> > 
> > -----Original Message-----
> > From: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com]
> 
> > Sent: Wednesday, June 21, 2006 10:33 AM
> > To: Tapestry users
> > Subject: RE: Logging error page into log4j
> > 
> > Hi James,
> > 
> > I created my own ExceptionPresenter and added the entry to the
> > hivemodule.xml
> > file and it now logs, but the original error display page is not showing.
> Is
> > there any way to display the error (as it does by default) and log it?
> > 
> > Thanks,
> > Amir
> > 
> > 
> > --- James Carman <ja...@carmanconsulting.com> wrote:
> > 
> > > Override the implementation of the tapestry.error.ExceptionPresenter
> > service
> > > point (until I change the way it works).  In your hivemodule.xml file:
> > > 
> > > <implementation service-id="tapestry.error.ExceptionPresenter">
> > >   <invoke-factory>
> > >     <construct class="com.myco.web.error.MyExceptionPresenter" />
> > >   </invoke-factory>
> > > </implementation>
> > > 
> > > -----Original Message-----
> > > From: amirsguard-tapestry@yahoo.com
> [mailto:amirsguard-tapestry@yahoo.com]
> > 
> > > Sent: Wednesday, June 21, 2006 9: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: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > 
> > > 
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > 
> > > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> > 
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Logging error page into log4j

Posted by James Carman <ja...@carmanconsulting.com>.
Copy the definition from the original hivemodule.xml:

<implementation service-id="tapestry.error.ExceptionPresenter">
<invoke-factory>
      <construct class="com.myco.web.error.MyExceptionPresenter">
        <set-object property="exceptionPageName" 
                       value="infrastructure:exceptionPageName"/>
        <set-object property="requestExceptionReporter"
                       value="infrastructure:requestExceptionReporter"/>
        <set-object property="responseRenderer"
                      value="infrastructure:responseRenderer"/>
      </construct>
    </invoke-factory>
</implementation>
-----Original Message-----
From: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com] 
Sent: Wednesday, June 21, 2006 10:46 AM
To: James Carman; 'Tapestry users'
Subject: RE: Logging error page into log4j

I wish it was that simple, but it's not working! The problem is that the
_exceptionPageName field is not being set. When I removed the hivemodule.xml
entry, the field gets populated with "Exception". So I tried this just to
see
if it works:

	 @Override
	public void presentException(final IRequestCycle cycle, final
Throwable cause)
{
		 logger.error(cause);
		 setExceptionPageName("Exception");
		 super.presentException(cycle, cause);
	 }

I still get a blank page!

--- James Carman <ja...@carmanconsulting.com> wrote:

> Just extend ExceptionPresenterImpl and call your superclass'
implementation!
> :-)  Ain't object-oriented programming great?
> 
> 
> -----Original Message-----
> From: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com]

> Sent: Wednesday, June 21, 2006 10:33 AM
> To: Tapestry users
> Subject: RE: Logging error page into log4j
> 
> Hi James,
> 
> I created my own ExceptionPresenter and added the entry to the
> hivemodule.xml
> file and it now logs, but the original error display page is not showing.
Is
> there any way to display the error (as it does by default) and log it?
> 
> Thanks,
> Amir
> 
> 
> --- James Carman <ja...@carmanconsulting.com> wrote:
> 
> > Override the implementation of the tapestry.error.ExceptionPresenter
> service
> > point (until I change the way it works).  In your hivemodule.xml file:
> > 
> > <implementation service-id="tapestry.error.ExceptionPresenter">
> >   <invoke-factory>
> >     <construct class="com.myco.web.error.MyExceptionPresenter" />
> >   </invoke-factory>
> > </implementation>
> > 
> > -----Original Message-----
> > From: amirsguard-tapestry@yahoo.com
[mailto:amirsguard-tapestry@yahoo.com]
> 
> > Sent: Wednesday, June 21, 2006 9: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: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Logging error page into log4j

Posted by am...@yahoo.com.
I wish it was that simple, but it's not working! The problem is that the
_exceptionPageName field is not being set. When I removed the hivemodule.xml
entry, the field gets populated with "Exception". So I tried this just to see
if it works:

	 @Override
	public void presentException(final IRequestCycle cycle, final Throwable cause)
{
		 logger.error(cause);
		 setExceptionPageName("Exception");
		 super.presentException(cycle, cause);
	 }

I still get a blank page!

--- James Carman <ja...@carmanconsulting.com> wrote:

> Just extend ExceptionPresenterImpl and call your superclass' implementation!
> :-)  Ain't object-oriented programming great?
> 
> 
> -----Original Message-----
> From: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com] 
> Sent: Wednesday, June 21, 2006 10:33 AM
> To: Tapestry users
> Subject: RE: Logging error page into log4j
> 
> Hi James,
> 
> I created my own ExceptionPresenter and added the entry to the
> hivemodule.xml
> file and it now logs, but the original error display page is not showing. Is
> there any way to display the error (as it does by default) and log it?
> 
> Thanks,
> Amir
> 
> 
> --- James Carman <ja...@carmanconsulting.com> wrote:
> 
> > Override the implementation of the tapestry.error.ExceptionPresenter
> service
> > point (until I change the way it works).  In your hivemodule.xml file:
> > 
> > <implementation service-id="tapestry.error.ExceptionPresenter">
> >   <invoke-factory>
> >     <construct class="com.myco.web.error.MyExceptionPresenter" />
> >   </invoke-factory>
> > </implementation>
> > 
> > -----Original Message-----
> > From: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com]
> 
> > Sent: Wednesday, June 21, 2006 9: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: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Logging error page into log4j

Posted by James Carman <ja...@carmanconsulting.com>.
Just extend ExceptionPresenterImpl and call your superclass' implementation!
:-)  Ain't object-oriented programming great?


-----Original Message-----
From: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com] 
Sent: Wednesday, June 21, 2006 10:33 AM
To: Tapestry users
Subject: RE: Logging error page into log4j

Hi James,

I created my own ExceptionPresenter and added the entry to the
hivemodule.xml
file and it now logs, but the original error display page is not showing. Is
there any way to display the error (as it does by default) and log it?

Thanks,
Amir


--- James Carman <ja...@carmanconsulting.com> wrote:

> Override the implementation of the tapestry.error.ExceptionPresenter
service
> point (until I change the way it works).  In your hivemodule.xml file:
> 
> <implementation service-id="tapestry.error.ExceptionPresenter">
>   <invoke-factory>
>     <construct class="com.myco.web.error.MyExceptionPresenter" />
>   </invoke-factory>
> </implementation>
> 
> -----Original Message-----
> From: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com]

> Sent: Wednesday, June 21, 2006 9: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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Logging error page into log4j

Posted by am...@yahoo.com.
Hi James,

I created my own ExceptionPresenter and added the entry to the hivemodule.xml
file and it now logs, but the original error display page is not showing. Is
there any way to display the error (as it does by default) and log it?

Thanks,
Amir


--- James Carman <ja...@carmanconsulting.com> wrote:

> Override the implementation of the tapestry.error.ExceptionPresenter service
> point (until I change the way it works).  In your hivemodule.xml file:
> 
> <implementation service-id="tapestry.error.ExceptionPresenter">
>   <invoke-factory>
>     <construct class="com.myco.web.error.MyExceptionPresenter" />
>   </invoke-factory>
> </implementation>
> 
> -----Original Message-----
> From: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com] 
> Sent: Wednesday, June 21, 2006 9: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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: Logging error page into log4j

Posted by James Carman <ja...@carmanconsulting.com>.
Override the implementation of the tapestry.error.ExceptionPresenter service
point (until I change the way it works).  In your hivemodule.xml file:

<implementation service-id="tapestry.error.ExceptionPresenter">
  <invoke-factory>
    <construct class="com.myco.web.error.MyExceptionPresenter" />
  </invoke-factory>
</implementation>

-----Original Message-----
From: amirsguard-tapestry@yahoo.com [mailto:amirsguard-tapestry@yahoo.com] 
Sent: Wednesday, June 21, 2006 9: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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org