472,794 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,794 software developers and data experts.

Error Logging

I am trying to implement database error logging in my asp.net application.
When I inspect the exception variable, I see that there is a property called
'procedure' which I believe is the procedure or fucntion that caused the
error. How can I get at that variable to write it to my error log?

Thanks,
Denise
Nov 19 '05 #1
4 1234
We recently discussed this over at DevelopMentor's listserv:

http://discuss.develop.com/archives/...B&P=R3885&I=-3
http://discuss.develop.com/archives/...B&P=R3787&I=-3
-Brock
DevelopMentor
http://staff.develop.com/ballen
I am trying to implement database error logging in my asp.net
application. When I inspect the exception variable, I see that there
is a property called 'procedure' which I believe is the procedure or
fucntion that caused the error. How can I get at that variable to
write it to my error log?

Thanks,
Denise


Nov 19 '05 #2
Brock,

Thanks for your reply. But perhaps this is not the correct link. I don't
see any mention of referencing the 'procedure' property of an exception.

Denise
"Brock Allen" wrote:
We recently discussed this over at DevelopMentor's listserv:

http://discuss.develop.com/archives/...B&P=R3885&I=-3
http://discuss.develop.com/archives/...B&P=R3787&I=-3
-Brock
DevelopMentor
http://staff.develop.com/ballen
I am trying to implement database error logging in my asp.net
application. When I inspect the exception variable, I see that there
is a property called 'procedure' which I believe is the procedure or
fucntion that caused the error. How can I get at that variable to
write it to my error log?

Thanks,
Denise


Nov 19 '05 #3
AFAIK, the 'Procedure' property is available specifically for exceptions
that are of type SqlException, and it tells you the name of the SQL Server
stored procedure that threw an exception (perhaps other exception types have
a 'Procedure' as well - but not "otherwise uncategorized" exceptions).

Here is a snippet I have in my exception logging routine that writes out the
information. It tells me the name of the specific SQL Server stored
procedure that choked (this is the 'Procedure' you are asking about) and the
specific line number etc. very helpful to have this info:

if (exIncoming is SqlException) {
SqlException e = (SqlException) exIncoming;

//Exception Type
MyWriter.WriteElementString(@"ExceptionType", "SqlException");

// Exception Details
for (int i=0; i < e.Errors.Count; i++) {
MyWriter.WriteStartElement(@"ExceptionDetails");
MyWriter.WriteElementString(@"Message",
HttpUtility.HtmlEncode(e.Errors[i].Message));
MyWriter.WriteElementString(@"LineNumber",
HttpUtility.HtmlEncode(e.Errors[i].LineNumber.ToString()));
MyWriter.WriteElementString(@"Procedure",
HttpUtility.HtmlEncode(e.Errors[i].Procedure));
MyWriter.WriteElementString(@"SQLErrorNumber",
HttpUtility.HtmlEncode(e.Errors[i].Number.ToString()));
MyWriter.WriteElementString(@"SQLServerName",
HttpUtility.HtmlEncode(e.Errors[i].Server));
MyWriter.WriteElementString(@"Provider",
HttpUtility.HtmlEncode(e.Errors[i].Source));
MyWriter.WriteElementString(@"SQLStateValue",
HttpUtility.HtmlEncode(e.Errors[i].State.ToString()));
MyWriter.WriteEndElement(); // End Exception Details
}
}

HTH !
"Denise" <De****@discussions.microsoft.com> wrote in message
news:10**********************************@microsof t.com...
I am trying to implement database error logging in my asp.net application.
When I inspect the exception variable, I see that there is a property
called
'procedure' which I believe is the procedure or fucntion that caused the
error. How can I get at that variable to write it to my error log?

Thanks,
Denise

Nov 19 '05 #4
Hmm, well there is no Procedure property that I can see. Perhaps you're looking
for:

ex.InnerException.TargetSite.Name

The one thing to note about exceptions in ASP.NET is that there are two categories
in essence. There are the ones your code caused and then there are other
ones that are raised by ASP.NET due to configuration errors and compiler
errors and things like that. When you receive the notification in the Application_Error
event in global.asax you usually check for which category the exception is
in. If it's in the first category then the type of exception thrown is the
HttpUnhandledException. If it's the second category then it's some other
excetionon (ConfgurationException for example). So you tend to write your
code like this:

void Application_Error(Object sender, EventArgs e)
{
Exception ex = Context.Error;
if (ex is HttpUnhandledException)
{
ex = Context.Error.InnerException;
}

// now log ex
}

So if you want the name of the method where the exception was raised, go
look for ex.TargetSite.Name. The other two good pieces of info are Source
which is the assembly and StackTarce which is usually crucial when tracking
down the error. If you just call Exception.ToString() you get all of that
info in a nice neat package. That's what the link I posted was trying to
show :S

-Brock
DevelopMentor
http://staff.develop.com/ballen
Brock,

Thanks for your reply. But perhaps this is not the correct link. I
don't see any mention of referencing the 'procedure' property of an
exception.

Denise

"Brock Allen" wrote:
We recently discussed this over at DevelopMentor's listserv:

http://discuss.develop.com/archives/...L=DOTNET-WEB&P
=R3885&I=-3

http://discuss.develop.com/archives/...L=DOTNET-WEB&P
=R3787&I=-3

-Brock
DevelopMentor
http://staff.develop.com/ballen
I am trying to implement database error logging in my asp.net
application. When I inspect the exception variable, I see that
there is a property called 'procedure' which I believe is the
procedure or fucntion that caused the error. How can I get at that
variable to write it to my error log?

Thanks,
Denise


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
5
by: Tony Wright | last post by:
Hi, I am having a problem installing an msi for a web site. The error message I am getting is: "The specified path 'http://mipdev05/features/Fas2' is unavailable. The Internet Information...
0
by: Rhino | last post by:
I've written several Java stored procedures now (DB2 V7.2) and I'd like to write down a few "best practices" for reference so that I will have them handy for future development. Would the...
10
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through...
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
4
by: sm | last post by:
Hi, I have a couple of questions with regards to handling errors and exceptions. 1. If I use On Error goto Errhandler ... Errhandler:
7
by: flupke | last post by:
Hi, i'm getting errors with the log module concerning RotatingFileHandler. I'm using Python 2.4.3 on Windows XP SP2. This used to work in previous python versions but since i upgraded to 2.4.3...
0
by: Roopesh | last post by:
Hi I am trying to use RotatingFileHandler, in the foll way : rootLogger = logging.getLogger('') rootLogger.setLevel(logging.DEBUG) rotatingHandler =...
9
by: Rasika WIJAYARATNE | last post by:
Hi guys, Please check this out: http://rkwcoding.blogspot.com/2007/07/error-logging.html
2
by: =?Utf-8?B?UG9sbHkgQW5uYQ==?= | last post by:
Hi, I have been successfully using the EHAB & Logging Application Block. Now however I get the error below and looking on line I was told that I have not set references to all the dlls. I have...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.