ASP 101 - Active Server Pages 101 - Web04
The Place ASP Developers Go!

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash



 Top ASP 101 Stories Top ASP 101 Stories
Getting Scripts to Run on a Schedule
The Top 10 ASP Links @ Microsoft.com
What is Adovbs.inc and Why Do I Need It?

QUICK TIP:
Host ASP Sites on Non-ASP Servers
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates


Implementing Error Logging in ASP 3.0

Implementing Error Logging in ASP 3.0

by Carvin Wilson

Overview

It is important to know what is going on with your site in development and production. By implementing proper error logging, you can quickly track down errors, and provide your team members with enhanced error information. With the new ASP Error object you can create a simple and effective logging system.

ASP Error Object

Did I tell you I love the new ASP Error object? It finally enables developers to control page execution. This object is used to retrieve details of the last error that occurred within an ASP page. Combine that with the ability to create custom error pages, and you have a pretty powerful tool within the development shack.

The error object consists of nine properties; however, I will only mention the properties used within the demo.

ASPDescription - returns a description for all non-ASP errors.
Category - the evil being, external object, or script that caused the error.
Column - column position of the rogue character.
Description - description of ASP error.
File - the ASP file that caused the error.
Line - the line number of the evil code.
Source - the actual evil code that caused the error.

Why should I implement error logging?

Reason #1

In production, I create an agent that monitors the error table and notifies me via e-mail once an error occurs. If you are monitoring multiple sites, this can be extremely handy and useful. The detailed error information allows me to get to the root of the problem quickly.

Reason #2

The typical development staff usually has one or two master gurus monitoring several junior code warriors. The average day is usually spent helping them track-down simple coding errors. Well, what if you could give them a way to trace down the errors without bugging you every 30 minutes? This would definitely increase productivity within the development shack. The error.asp contains all the ASP error codes as well as a detailed description for each error. This page can be routinely updated to display fixes and things to try before running to the master gurus.

Reason #3

As a manager it is important to monitor the effectiveness of your staff. By logging errors you can track common mistakes and address them with a training class.

Reason #4

When you have 6 to 12 web developers it is a lot easier to query a table for information, than trying to drain it out of the new hire or freshly minted consultant. Besides, it really scares them when you call their extension and tell them the answer to the question that they were getting ready to ask you =).

How do I implement error logging?

Almost all ASP errors throw the "500 - Internal Server Error", we are going to replace this page with a custom asp script that logs information to a database. I usually create two versions of this file, one for development and another for production.

The steps below walk you through implementing this feature.

Step 1 - Create your table. I have included a SQL script to run against SQL Server.

Step 2 - Place the error.asp file on your server. Make sure you change the connection string information.

Step 3 - Right-click on the directory or site and select the properties option. Choose the custom errors tab.

Step 4 - Select the 500:100 HTTP Error and hit edit properties.

Step 5 - Change the message type to URL and point to error.asp.

Now lets cause some errors. Load the error_demo.asp file included with the demo, it should cause an error in a flash! You will then receive a well-formatted and very detailed error screen.

Click the link to see actual demo.

http://www.harborviewsolutions.com/resourceweb/demo/error_demo.asp.

Summary

I hope this article has given you some ideas and insight into error logging. No matter what version of ASP you are using, the benefits are still the same. If you have any questions, comments, or problems my contact information is listed here. For those of you who are interested, the demo files are available here for download.


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers