Solved

ASP - Capture and log errors, timeouts - best practices

Posted on 2016-09-02
3
37 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
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…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

708 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

14 Experts available now in Live!

Get 1:1 Help Now