Solved

ASP - Capture and log errors, timeouts - best practices

Posted on 2016-09-02
3
47 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
  • 2
3 Comments
 
LVL 32

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 52

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 32

Expert Comment

by:Big Monty
ID: 41808389
2 best answers
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how the fundamental information of how to create a table.

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now