Solved

ASP - Capture and log errors, timeouts - best practices

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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
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.
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.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

739 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