[prev in list] [next in list] [prev in thread] [next in thread] 

List:       log4net-user
Subject:    Re: Customize the exception output
From:       "Sean Carlin" <seancarlin () gmail ! com>
Date:       2006-06-23 22:10:53
Message-ID: ad1ed7ed0606231510q3839540eja107997958c88d38 () mail ! gmail ! com
[Download RAW message or body]

Hi Ron,

I noticed that the Exception Information part can really vary per exception,
so I don't know how well a pattern output will work.  It would be nice to
understand what the Enterprise Library does to figure this stuff out.  I may
have to reverse engineer the code with a tool to see.  Yes, Ent Lib does
spit out "Void ExecuteScripts(System.String,System.String[], Boolean,
Boolean)."

Another variation (of many, apparently):

1) Exception Information
*********************************************
Exception Type: System.Security.SecurityException
Action: 0
PermissionType: NULL
FirstPermissionThatFailed: NULL
PermissionState: NULL
Demanded: NULL
GrantedSet: NULL
RefusedSet: NULL
DenySetInstance: NULL
PermitOnlySetInstance: NULL
FailedAssemblyInfo: NULL
Method: NULL
Zone: MyComputer
Url: NULL
Message: The current user has tried to access a secure area with an
unauthorized role.
Data: System.Collections.ListDictionaryInternal
TargetSite: Void AccessDenied(Boolean)
HelpLink: NULL
Source:



On 6/21/06, Ron Grabowski <rongrabowski@yahoo.com> wrote:
> 
> My initial thought was this:
> 
> <layout type="log4net.Layout.PatternLayout">
> <![CDATA[
> %counter) Exception Information
> 
> *********************************************
> 
> Exception Type: %exception{type}
> 
> Message: %exception{message}
> 
> Data: ???
> 
> TargetSite: NULL
> 
> HelpLink: NULL
> 
> Source: NULL
> ]]>
> </layout>
> 
> I don't think the current exception pattern implementation accepts
> additional parameters.
> 
> I remember seeing a counter pattern somewhere but I can't seem to find
> it now.
> 
> What should go in the "Data:" part of your example?
> 
> Does EntLib really show this text "Void ExecuteScripts(System.String,
> System.String[], Boolean, Boolean)" or does it just show
> "ExecuteScripts"?
> 
> I would create an ExtendedPatternLayout that registers additional
> converters and have your appenders use that.
> 
> Create a JIRA issue if you think some of these patterns should be part
> of PatternLayout.
> 
> --- Sean Carlin <seancarlin@gmail.com> wrote:
> 
> > Hi,
> > 
> > I've had a request from the developers at my company to modify the
> > way in
> > which log4net outputs exceptions to the log.  This would need to take
> > effect
> > in my EventLogAppender and AdoNetAppender.  Will I need to create my
> > own
> > custom class similar to ExceptionLayout or a custom class similar to
> > ExceptionPatternConverter?  How can I specify this change to the
> > EventLogAppender?
> > 
> > The request is to format the exception more like the way the .NET
> > Enterprise
> > Library did in .NET 1.1.:
> > 
> > 
> > 1) Exception Information
> > 
> > *********************************************
> > 
> > Exception Type: X.WebApps.NewsRoom.WebControls.NewsSystemException
> > 
> > Message: Could not retrieve a list of articles from the category
> > 
> > Data: System.Collections.ListDictionaryInternal
> > 
> > TargetSite: NULL
> > 
> > HelpLink: NULL
> > 
> > Source: NULL
> > 
> > 2) Exception Information
> > 
> > *********************************************
> > 
> > Exception Type: System.Exception
> > 
> > Message: An error occurred while processing the required SQL script:
> > D:\WebSites\X\WebAppsFolders\WebAppsCommonFiles\\scripts\core.config
> > 
> > Data: System.Collections.ListDictionaryInternal
> > 
> > TargetSite: Void ExecuteScripts(System.String, System.String[],
> > Boolean,
> > Boolean)
> > 
> > HelpLink: NULL
> > 
> > Source: X.WebApps.CoreLibrary.X.X
> > 
> > StackTrace Information
> > 
> > *********************************************
> > 
> > at X.WebApps.CoreSystem.ExecuteScripts(String path, String[] scripts,
> > Boolean trapExceptions, Boolean sendAppPath)
> > 
> > at X.WebApps.CoreSystem.SystemInit()
> > 
> > at X.WebApps.CoreSystem..ctor(String application)
> > 
> > at
> > 
> 
> X.WebApps.NewsRoom.WebControls.NewsArticleDisplayer.GetNewsArticleAndCategory
> (Category&
> > newsCategory, Article& newsArticle)
> > 
> > Here is a sample of what is being output by the default format:
> > 
> > System.Exception: Testing application error handling from the
> > DevCenter/ApplicationErrorTest.aspx form. --->
> > System.ArrayTypeMismatchException: Oh my gosh some sort of array
> > mismatch
> > occurred in this fake class! Error! Error!
> > at RemoteNet.Zapenza.Utility.TestClass..ctor() in
> > 
> 
> C:\Solutions\CIProjects\RemoteNet\Zapenza\Working\Source\RemoteNet.Zapenza.Utility\TestClass.cs:line
> 
> > 11
> > at DevCenter_ApplicationErrorTest.lnkApplicationError_Click(Object
> > sender,
> > EventArgs e) in
> > 
> 
> c:\Solutions\CIProjects\RemoteNet\Zapenza\Working\Source\RemoteNet.Zapenza.Web.UI\DevCenter\ApplicationErrorTest.aspx.cs:line
> 
> > 24
> > --- End of inner exception stack trace ---
> > at DevCenter_ApplicationErrorTest.lnkApplicationError_Click(Object
> > sender,
> > EventArgs e) in
> > 
> 
> c:\Solutions\CIProjects\RemoteNet\Zapenza\Working\Source\RemoteNet.Zapenza.Web.UI\DevCenter\ApplicationErrorTest.aspx.cs:line
> 
> > 28
> > at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
> > at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
> > eventArgument)
> > at
> > 
> 
> System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent
>  (String
> > eventArgument)
> > at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
> > sourceControl, String eventArgument)
> > at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
> > postData)
> > at System.Web.UI.Page.ProcessRequestMain(Boolean
> > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
> > 
> 
> 


[Attachment #3 (text/html)]

Hi Ron,<br><br>I noticed that the Exception Information part can really vary per \
exception, so I don't know how well a pattern output will work.&nbsp; It would be \
nice to understand what the Enterprise Library does to figure this stuff out.&nbsp; I \
may have to reverse engineer the code with a tool to see.&nbsp; Yes, Ent Lib does \
spit out &quot;Void ExecuteScripts( System.String,System.String[], Boolean, \
Boolean).&quot;<br><br>Another variation (of many, apparently):<br><br>1) Exception \
Information<br>*********************************************<br>Exception Type: \
System.Security.SecurityException <br>Action: 0<br>PermissionType: \
NULL<br>FirstPermissionThatFailed: NULL<br>PermissionState: NULL<br>Demanded: \
NULL<br>GrantedSet: NULL<br>RefusedSet: NULL<br>DenySetInstance: \
NULL<br>PermitOnlySetInstance: NULL<br>FailedAssemblyInfo: NULL <br>Method: \
NULL<br>Zone: MyComputer<br>Url: NULL<br>Message: The current user has tried to \
access a secure area with an unauthorized role.<br>Data: \
System.Collections.ListDictionaryInternal<br>TargetSite: Void AccessDenied(Boolean) \
<br>HelpLink: NULL<br>Source:<br><br><br><br><div><span class="gmail_quote">On \
6/21/06, <b class="gmail_sendername">Ron Grabowski</b> &lt;<a \
href="mailto:rongrabowski@yahoo.com">rongrabowski@yahoo.com</a>&gt; wrote:</span> \
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); \
margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">My initial thought was \
this:<br><br>&lt;layout type=&quot;log4net.Layout.PatternLayout&quot;&gt; \
<br>&lt;![CDATA[<br>%counter) Exception \
Information<br><br>*********************************************<br><br>Exception \
Type: %exception{type}<br><br>Message: %exception{message}<br><br>Data: \
???<br><br>TargetSite: NULL <br><br>HelpLink: NULL<br><br>Source: \
NULL<br>]]&gt;<br>&lt;/layout&gt;<br><br>I don't think the current exception pattern \
implementation accepts<br>additional parameters.<br><br>I remember seeing a counter \
pattern somewhere but I can't seem to find <br>it now.<br><br>What should go in the \
&quot;Data:&quot; part of your example?<br><br>Does EntLib really show this text \
&quot;Void ExecuteScripts(System.String,<br>System.String[], Boolean, Boolean)&quot; \
or does it just show <br>&quot;ExecuteScripts&quot;?<br><br>I would create an \
ExtendedPatternLayout that registers additional<br>converters and have your appenders \
use that.<br><br>Create a JIRA issue if you think some of these patterns should be \
part <br>of PatternLayout.<br><br>--- Sean Carlin &lt;<a \
href="mailto:seancarlin@gmail.com">seancarlin@gmail.com</a>&gt; \
wrote:<br><br>&gt;&nbsp;&nbsp;Hi,<br>&gt;<br>&gt; I've had a request from the \
developers at my company to modify the <br>&gt; way in<br>&gt; which log4net outputs \
exceptions to the log.&nbsp;&nbsp;This would need to take<br>&gt; effect<br>&gt; in \
my EventLogAppender and AdoNetAppender.&nbsp;&nbsp;Will I need to create my<br>&gt; \
own<br>&gt; custom class similar to ExceptionLayout or a custom class similar to \
<br>&gt; ExceptionPatternConverter?&nbsp;&nbsp;How can I specify this change to \
the<br>&gt; EventLogAppender?<br>&gt;<br>&gt; The request is to format the exception \
more like the way the .NET<br>&gt; Enterprise<br>&gt; Library did in .NET  \
1.1.:<br>&gt;<br>&gt;<br>&gt; 1) Exception Information<br>&gt;<br>&gt; \
*********************************************<br>&gt;<br>&gt; Exception Type: \
X.WebApps.NewsRoom.WebControls.NewsSystemException<br>&gt;<br>&gt; Message: Could not \
retrieve a list of articles from the category <br>&gt;<br>&gt; Data: \
System.Collections.ListDictionaryInternal<br>&gt;<br>&gt; TargetSite: \
NULL<br>&gt;<br>&gt; HelpLink: NULL<br>&gt;<br>&gt; Source: NULL<br>&gt;<br>&gt; 2) \
Exception Information<br>&gt;<br>&gt; ********************************************* \
<br>&gt;<br>&gt; Exception Type: System.Exception<br>&gt;<br>&gt; Message: An error \
occurred while processing the required SQL script:<br>&gt; \
D:\WebSites\X\WebAppsFolders\WebAppsCommonFiles\\scripts\core.config<br>&gt;<br> &gt; \
Data: System.Collections.ListDictionaryInternal<br>&gt;<br>&gt; TargetSite: Void \
ExecuteScripts(System.String, System.String[],<br>&gt; Boolean,<br>&gt; \
Boolean)<br>&gt;<br>&gt; HelpLink: NULL<br>&gt;<br>&gt; Source:  \
X.WebApps.CoreLibrary.X.X<br>&gt;<br>&gt; StackTrace Information<br>&gt;<br>&gt; \
*********************************************<br>&gt;<br>&gt; at \
X.WebApps.CoreSystem.ExecuteScripts(String path, String[] scripts,<br>&gt; Boolean \
trapExceptions, Boolean sendAppPath) <br>&gt;<br>&gt; at \
X.WebApps.CoreSystem.SystemInit()<br>&gt;<br>&gt; at \
X.WebApps.CoreSystem..ctor(String application)<br>&gt;<br>&gt; \
at<br>&gt;<br>X.WebApps.NewsRoom.WebControls.NewsArticleDisplayer.GetNewsArticleAndCategory
 (Category&amp;<br>&gt; newsCategory, Article&amp; newsArticle)<br>&gt;<br>&gt; Here \
is a sample of what is being output by the default format:<br>&gt;<br>&gt; \
System.Exception: Testing application error handling from the<br> &gt; \
DevCenter/ApplicationErrorTest.aspx form. ---&gt;<br>&gt; \
System.ArrayTypeMismatchException: Oh my gosh some sort of array<br>&gt; \
mismatch<br>&gt; occurred in this fake class! Error! Error!<br>&gt; at \
RemoteNet.Zapenza.Utility.TestClass..ctor () \
in<br>&gt;<br>C:\Solutions\CIProjects\RemoteNet\Zapenza\Working\Source\RemoteNet.Zapenza.Utility\TestClass.cs:line<br>&gt; \
11<br>&gt; at DevCenter_ApplicationErrorTest.lnkApplicationError_Click(Object<br>&gt; \
sender,<br> &gt; EventArgs e) \
in<br>&gt;<br>c:\Solutions\CIProjects\RemoteNet\Zapenza\Working\Source\RemoteNet.Zapenza.Web.UI\DevCenter\ApplicationErrorTest.aspx.cs:line<br>&gt; \
24<br>&gt; --- End of inner exception stack trace ---<br> &gt; at \
DevCenter_ApplicationErrorTest.lnkApplicationError_Click(Object<br>&gt; \
sender,<br>&gt; EventArgs e) \
in<br>&gt;<br>c:\Solutions\CIProjects\RemoteNet\Zapenza\Working\Source\RemoteNet.Zapenza.Web.UI\DevCenter\ApplicationErrorTest.aspx.cs:line
 <br>&gt; 28<br>&gt; at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs \
e)<br>&gt; at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String<br>&gt; \
eventArgument)<br>&gt; \
at<br>&gt;<br>System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent
 (String<br>&gt; eventArgument)<br>&gt; at \
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler<br>&gt; sourceControl, \
String eventArgument)<br>&gt; at \
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection<br>&gt; postData) <br>&gt; \
at System.Web.UI.Page.ProcessRequestMain(Boolean<br>&gt; \
includeStagesBeforeAsyncPoint, Boolean \
includeStagesAfterAsyncPoint)<br>&gt;<br><br></blockquote></div><br>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic