Solved

ASP - Capture and log errors, timeouts - best practices

Posted on 2016-09-02
3
67 Views
Last Modified: 2016-09-21
I have a system running Win Server 2008 R2, with IIS.
I'd like to be able to monitor any timeouts, ASP errors, etc.

I have some logging enabled, but not sure if I'm approaching this in the best manner.
Looking for some best practices...

Any suggestions would be great!

Thanks,

ED
0
Comment
Question by:edalzell01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
Big Monty earned 250 total points (awarded by participants)
ID: 41781519
built in logging with classic asp is almost non-existent, you'll need to manually do it. this assumes you've turned on basic logging within IIS, which'll write to the event viewer as well as log files.

I did manage to find this logging class, not sure if it would be of any use to you:

https://gist.github.com/CarlRevell/8184656

to manually write to the log file, use the AppendToLog method:

http://www.w3schools.com/asp/met_appendtolog.asp
1
 
LVL 53

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 250 total points (awarded by participants)
ID: 41782228
As mentioned, there is nothing built in.  But you can track errors from your asp code.

If you try this
<%
On Error Resume Next


response.rite "I spelled write wrong and this should error"

response.write "This line works"

If Err.number<>0 then
 
      Response.Write "An Error Has Occurred on this page!<BR>"
      Response.Write "The Error Number is: " & Err.number & "<BR>"
      Response.Write "The Description given is: " & Err.Description & "<BR>"

End If

%>

Open in new window


Running this code snippet should show you how you can create your own error trapping.

' TOP OF EVERY PAGE
On Error Resume Next

' YOUR ASP AND HTML CODE HERE

' BOTTOM OF EVERY PAGE
If Err.number<>0 then
 
      Response.Write "An Error Has Occurred on this page!<BR>"
      Response.Write "The Error Number is: " & Err.number & "<BR>"
      Response.Write "The Description given is: " & Err.Description & "<BR>"

End If

Open in new window


The next step is you don't want to output the error information to the screen.  Instead, create yourself a log file using fso to write to a log file or create a separate log file for each error.  https://msdn.microsoft.com/en-us/library/6ee7s9w2(v=vs.84).aspx  My preference would be writing the error to the database and note the page name, ip, timestamp, any log in info if you use that and the error number and description.  That way you can easily report on this.

Time out errors may not show up depending on the reason.  If you have a log in system for instance and people complain that they get timed out.  More than likely it is from the idle time out or the app pool crashed IF you are using sessions.    If you are, switch out using sessions to cookies.  I have an article here on how to use a cookies for a log in system.  https://www.experts-exchange.com/articles/18259/User-Log-In-Using-A-Token.html  

session("test") = "abc" can also be response.cookies("test") = "abc"  http://www.w3schools.com/asp/asp_cookies.asp

These are all general possible fix's. Knowing more about what you are doing and what your users are experiencing can lead to a more detailed fix for you.
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 41808389
2 best answers
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question