473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 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 1256
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.