Solved

ASP - Capture and log errors, timeouts - best practices

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

Expert Comment

by:Big Monty
ID: 41808389
2 best answers
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

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…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to shrink a transaction log file down to a reasonable size.
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

785 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