You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Widerberg Marcus <Ma...@tetrapak.com> on 2007/02/01 12:15:35 UTC
Logging stack trace
Hello everyone,
Is there a way to add a stack trace to each log event for a certain
appender layout?
I have an errorappender, and when it receives an event to log, I would
like it to log the whole stack trace as well.
This is for debug and test purposes.
/marcus
RE: Logging stack trace
Posted by "Graham, Corey J." <co...@wamu.net>.
Our implementation handled this by creating a custom ExceptionRenderer,
so all of the properties of the exception can be formatted correctly -
including inner exceptions.
The configuration calls out our custom Renderer:
<renderer
renderingClass="MyApplication.log4net.ExceptionRenderer,
MyApplication.log4net "
renderedClass="System.Exception, mscorlib" />
Here the implemented custom renderer is
MyApplication.log4net.ExceptionRenderer, and it implements
IObjectRenderer. That leads to implementing RenderObject() where the
object is the exception instance. In our implementation we loop through
the inner exceptions in reverse order. We don't use the stack trace
property.
Then we implemented a custom layout, so when the LoggingEvent instance
is passed we can manage the exception string the way we want to, but
that's just icing on the cake.
Corey
-----Original Message-----
From: Widerberg Marcus [mailto:Marcus.Widerberg@tetrapak.com]
Sent: Thursday, February 01, 2007 3:16 AM
To: Log4NET User
Subject: Logging stack trace
Hello everyone,
Is there a way to add a stack trace to each log event for a certain
appender layout?
I have an errorappender, and when it receives an event to log, I would
like it to log the whole stack trace as well.
This is for debug and test purposes.
/marcus
RE: Logging stack trace
Posted by Widerberg Marcus <Ma...@tetrapak.com>.
Hello Wayne,
Thanks for your reply.
Is anyone aware of if there is an way to expose a stacktrace property so that I can add it to a layout? Either built-in or a suggestion for improvement?
/marcus
Wayne Bradney wrote:
> Marcus,
>
> Take a look at System.Diagnostics.StackTrace
>
>
>
>
> Wayne M. Bradney
> Chief Application Architect, Derivatives & Structured Products
>
> Wall Street Systems, 1290 Avenue of the Americas, 22nd Floor, New
> York, NY 10104
> Phone:
> +1 212 809 7200
> Direct Dial:
> +1 212 401 8239
> Mobile:
>
> Email:
> wayne.bradney@wallstreetsystems.com
> Web:
> www.wallstreetsystems.com
>
> Wall Street Systems - Empowering Treasury, Trading and Settlement
>
>
> -----Original Message-----
> From: Widerberg Marcus [mailto:Marcus.Widerberg@tetrapak.com]
> Sent: Thursday, February 01, 2007 9:08 AM
> To: Log4NET User
> Subject: RE: Logging stack trace
>
> Hello Harry,
>
> Thanks for your reply!
>
> I actually wanted to log a trace for each event, regardless if there
> was an exception thrown.
>
> May seem odd, but useful for debugging and testing processes.
>
> /marcus
>
> -----Original Message-----
> From: harry.douglass@pnc.com [mailto:harry.douglass@pnc.com]
> Sent: den 1 februari 2007 14:47
> To: Log4NET User
> Subject: Re: Logging stack trace
>
> Hi,Marcus.
>
> The best way I found to handle it, if I understand your question
> correctly, is to pass the entire exception object into the parameter,
> like so:
>
> try {
>
> SomeOperation();
>
> }catch(Exception e){
>
> log.Error(e);
> }
>
> Harry Douglass
> Consumer Lending Application Development
> X2-1035
>
>
>
>
>
>
> "Widerberg
>
> Marcus"
>
> <Marcus.Widerberg
> To
> @tetrapak.com> "Log4NET User"
>
>
> <lo...@logging.apache.org>
>
> 02/01/2007 06:15
> cc
> AM
>
>
> Subject
> Logging stack trace
>
> Please respond to
>
> "Log4NET User"
>
> <log4net-user@log
>
> ging.apache.org>
>
>
>
>
>
>
>
>
>
> Hello everyone,
>
> Is there a way to add a stack trace to each log event for a certain
> appender layout?
>
> I have an errorappender, and when it receives an event to log, I
> would like it to log the whole stack trace as well.
>
> This is for debug and test purposes.
>
> /marcus
>
>
>
> The contents of this email are the property of PNC. If it was not
> addressed to you, you have no legal right to read it. If you think
> you received it in error, please notify the sender. Do not forward or
> copy without permission of the sender. This message may contain an
> advertisement of a product or service and thus may constitute a
> commercial electronic mail message under US Law. PNC's postal address
> is 249 Fifth Avenue, Pittsburgh, PA 15222. If you do not wish to
> receive any additional advertising or promotional messages from PNC
> at this e-mail address, click here to Unsubscribe.
> https://pnc.p.delivery.net/m/u/pnc/uni/p.asp By unsubscribing to this
> message, you will be unsubscribed from all advertising or promotional
> messages from PNC. Removing your e-mail address from this mailing
> list will not affect your subscription to alerts, e-newsletters or
> account servicing e-mails.
RE: Logging stack trace
Posted by Wayne Bradney <Wa...@WallStreetSystems.com>.
Marcus,
Take a look at System.Diagnostics.StackTrace
Wayne M. Bradney
Chief Application Architect, Derivatives & Structured Products
Wall Street Systems, 1290 Avenue of the Americas, 22nd Floor, New York, NY 10104
Phone:
+1 212 809 7200
Direct Dial:
+1 212 401 8239
Mobile:
Email:
wayne.bradney@wallstreetsystems.com
Web:
www.wallstreetsystems.com
Wall Street Systems - Empowering Treasury, Trading and Settlement
-----Original Message-----
From: Widerberg Marcus [mailto:Marcus.Widerberg@tetrapak.com]
Sent: Thursday, February 01, 2007 9:08 AM
To: Log4NET User
Subject: RE: Logging stack trace
Hello Harry,
Thanks for your reply!
I actually wanted to log a trace for each event, regardless if there was
an exception thrown.
May seem odd, but useful for debugging and testing processes.
/marcus
-----Original Message-----
From: harry.douglass@pnc.com [mailto:harry.douglass@pnc.com]
Sent: den 1 februari 2007 14:47
To: Log4NET User
Subject: Re: Logging stack trace
Hi,Marcus.
The best way I found to handle it, if I understand your question
correctly, is to pass the entire exception object into the parameter,
like so:
try {
SomeOperation();
}catch(Exception e){
log.Error(e);
}
Harry Douglass
Consumer Lending Application Development
X2-1035
"Widerberg
Marcus"
<Marcus.Widerberg
To
@tetrapak.com> "Log4NET User"
<lo...@logging.apache.org>
02/01/2007 06:15
cc
AM
Subject
Logging stack trace
Please respond to
"Log4NET User"
<log4net-user@log
ging.apache.org>
Hello everyone,
Is there a way to add a stack trace to each log event for a certain
appender layout?
I have an errorappender, and when it receives an event to log, I would
like it to log the whole stack trace as well.
This is for debug and test purposes.
/marcus
The contents of this email are the property of PNC. If it was not
addressed to you, you have no legal right to read it. If you think you
received it in error, please notify the sender. Do not forward or copy
without permission of the sender. This message may contain an
advertisement of a product or service and thus may constitute a
commercial electronic mail message under US Law. PNC's postal address is
249 Fifth Avenue, Pittsburgh, PA 15222. If you do not wish to receive
any additional advertising or promotional messages from PNC at this
e-mail address, click here to Unsubscribe.
https://pnc.p.delivery.net/m/u/pnc/uni/p.asp By unsubscribing to this
message, you will be unsubscribed from all advertising or promotional
messages from PNC. Removing your e-mail address from this mailing list
will not affect your subscription to alerts, e-newsletters or account
servicing e-mails.
RE: Logging stack trace
Posted by Widerberg Marcus <Ma...@tetrapak.com>.
Hello Harry,
Thanks for your reply!
I actually wanted to log a trace for each event, regardless if there was
an exception thrown.
May seem odd, but useful for debugging and testing processes.
/marcus
-----Original Message-----
From: harry.douglass@pnc.com [mailto:harry.douglass@pnc.com]
Sent: den 1 februari 2007 14:47
To: Log4NET User
Subject: Re: Logging stack trace
Hi,Marcus.
The best way I found to handle it, if I understand your question
correctly, is to pass the entire exception object into the parameter,
like so:
try {
SomeOperation();
}catch(Exception e){
log.Error(e);
}
Harry Douglass
Consumer Lending Application Development
X2-1035
"Widerberg
Marcus"
<Marcus.Widerberg
To
@tetrapak.com> "Log4NET User"
<lo...@logging.apache.org>
02/01/2007 06:15
cc
AM
Subject
Logging stack trace
Please respond to
"Log4NET User"
<log4net-user@log
ging.apache.org>
Hello everyone,
Is there a way to add a stack trace to each log event for a certain
appender layout?
I have an errorappender, and when it receives an event to log, I would
like it to log the whole stack trace as well.
This is for debug and test purposes.
/marcus
The contents of this email are the property of PNC. If it was not
addressed to you, you have no legal right to read it. If you think you
received it in error, please notify the sender. Do not forward or copy
without permission of the sender. This message may contain an
advertisement of a product or service and thus may constitute a
commercial electronic mail message under US Law. PNC's postal address is
249 Fifth Avenue, Pittsburgh, PA 15222. If you do not wish to receive
any additional advertising or promotional messages from PNC at this
e-mail address, click here to Unsubscribe.
https://pnc.p.delivery.net/m/u/pnc/uni/p.asp By unsubscribing to this
message, you will be unsubscribed from all advertising or promotional
messages from PNC. Removing your e-mail address from this mailing list
will not affect your subscription to alerts, e-newsletters or account
servicing e-mails.
Re: Logging stack trace
Posted by ha...@pnc.com.
Hi,Marcus.
The best way I found to handle it, if I understand your question correctly,
is to pass the entire exception object into the parameter, like so:
try {
SomeOperation();
}catch(Exception e){
log.Error(e);
}
Harry Douglass
Consumer Lending Application Development
X2-1035
"Widerberg
Marcus"
<Marcus.Widerberg To
@tetrapak.com> "Log4NET User"
<lo...@logging.apache.org>
02/01/2007 06:15 cc
AM
Subject
Logging stack trace
Please respond to
"Log4NET User"
<log4net-user@log
ging.apache.org>
Hello everyone,
Is there a way to add a stack trace to each log event for a certain
appender layout?
I have an errorappender, and when it receives an event to log, I would
like it to log the whole stack trace as well.
This is for debug and test purposes.
/marcus
The contents of this email are the property of PNC. If it was not addressed to you, you have no legal right to read it. If you think you received it in error, please notify the sender. Do not forward or copy without permission of the sender. This message may contain an advertisement of a product or service and thus may constitute a commercial electronic mail message under US Law. PNC�s postal address is 249 Fifth Avenue, Pittsburgh, PA 15222. If you do not wish to receive any additional advertising or promotional messages from PNC at this e-mail address, click here to Unsubscribe. https://pnc.p.delivery.net/m/u/pnc/uni/p.asp By unsubscribing to this message, you will be unsubscribed from all advertising or promotional messages from PNC. Removing your e-mail address from this mailing list will not affect your subscription to alerts, e-newsletters or account servicing e-mails.