Getting Line #'s from error messages

Results 1 to 3 of 3

Thread: Getting Line #'s from error messages

  1. #1
    Join Date
    Dec 1969

    Default Getting Line #'s from error messages

    I&#039;ve got a routine in place using Application_Error in Global.asax. I use this to save information to a log file, and when an error occurs, I get an e-mail to check the log. I really need to start getting line #&#039;s, however. I&#039;ve got a similar function in regular .ASP, and it gives me the exact file name, error message, and line # where the error occurred. Using this info, I can usually fix these errors within 5 minutes. Without the line #, I have to guess at where the problem occurred, and often, I can&#039;t even duplicate the error.<BR><BR>Following is my routine, if anyone wants to make any suggestions, I would appreciate it:<BR><BR>[code language=""]<BR>Sub Application_Error(sender As Object, e As EventArgs)<BR> &#039;get reference to the source of the exception chain<BR> Dim FSO, FileName, OldInfo, TF<BR><BR> FSO = Server.CreateObject("Scripting.FileSystemObject")< BR> FileName = Replace(LCase(Server.MapPath("Alumni.asp")),"alumn i.asp","Error.Log")<BR> OldInfo = ""<BR> if not FSO.FileExists(FileName) then<BR> TF=FSO.CreateTextFile(FileName)<BR> else<BR> TF=FSO.OpenTextFile(FileName, 1) &#039; Open file for reading<BR> OldInfo = TF.ReadAll<BR> TF=Nothing<BR> TF=FSO.OpenTextFile(FileName, 2) &#039; Open file for writing.<BR> end if<BR> TF.WriteLine( OldInfo & vbCRLF & _<BR> "================================================= ===============================" & vbNewLine & _<BR> "Date/Time: " & DateTime.Now & vbNewLine & _<BR> "URL: " & Request.Path & " (Line #)" & vbNewLine & _<BR> "Error: " & Server.GetLastError.ToString() )<BR> TF.Close<BR> TF=Nothing<BR> FSO=Nothing<BR>End Sub<BR>[/code]<BR><BR>Thanks,<BR>Jesse

  2. #2
    Join Date
    Dec 1969

    Default Couple of issues....

    First, you shouldn&#039;t be using FSO. Check out the System.IO namespace instead. <BR><BR>Secondly, you really do *NOT* want the line numbers! The source lines go away when you do a release compile...They don&#039;t exist any more as far as the assembly is concerned. To keep references to them means that you need to keep all of the associated debugging information, which means taking a nasty performance hit across the board. <BR><BR>What will probably help you the most would be to record an exception&#039;s stack trace. That&#039;ll narrow your search down considerably, and it isn&#039;t going to cause the performance degradationg that you&#039;d see associated with using a debug build.

  3. #3

    Default RE: Couple of issues....

    If there isn&#039;t anything in the exception, check to see if there is something in it&#039;s .innerException

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts