Solved

mailing myself the trace information

Posted on 2014-02-10
9
225 Views
Last Modified: 2014-02-12
When an exception is thrown I mail myself the exception data, logged in user, ip address, stuff like that.

I'd like to mail the trace information. Is there a way to retrieve that as a string to mail it?

thanks!
0
Comment
Question by:Starr Duskk
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 100 total points
ID: 39849467
Call ToString on your exception object.

Try
    'Your Code
Catch ex As Exception
    Debug.Writeline(ex.ToString)
End Try
0
 
LVL 12

Expert Comment

by:ktaczala
ID: 39849571
your better off sending it as an attachment
0
 
LVL 10

Expert Comment

by:John Claes
ID: 39850676
the exception has a stacktrace attribute you can use.
you can retreive the exception using try - catch
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 2

Author Comment

by:Starr Duskk
ID: 39850792
I must be missing something. I don't see an answer I can use in any of the responses.
0
 
LVL 40
ID: 39850954
You said that you mail yourself information, so I assumed that you knew how to send mail from your application.

All you have to add to get the trace is to had the result of ex.ToString in your Try...Catch...End Try.
0
 
LVL 12

Accepted Solution

by:
ktaczala earned 400 total points
ID: 39850958
Write to a trace log, by default it will be here: My.Application.Info.DirectoryPath

Then in your script to build your mail message add this:
Dim attfile As New Attachment(System.IO.Path.GetTempPath & "\TraceLog.log")
 **Whatever you call your log file
then  add it to the mail message:
mymailmessage.attachments.add(attfile)

send the message
0
 
LVL 12

Expert Comment

by:ktaczala
ID: 39850973
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 39852513
What must be confusing me is that when I run this page on Trace Write and Trace Warn, it has a bunch of information. I do understand how to retrieve an exception as a string. I thought I could retrieve the information displayed on this page and send it.

<%@ Page Language="VB" Trace="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
  
    Try
      If (IsPostBack) Then
        
        Select Case Request.Form("__EVENTTARGET")
          Case "WarnLink"
            Throw New ArgumentException("Trace warn.")
          Case "WriteLink"
            Throw New InvalidOperationException("Trace write.")
          Case Else
            Throw New ArgumentException("General exception.")
        End Select  
      End If
    Catch ae As ArgumentException
      Trace.Warn("Exception Handling", "Warning: Page_Load.", ae)
    Catch ioe As InvalidOperationException
      Trace.Write("Exception Handling", "Exception: Page_Load.", ioe)
    End Try
  End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Trace Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        http://msdn.microsoft.com/en-us/library/z48bew18(v=vs.85).aspx
        <br /><br />
      <asp:LinkButton id="WriteLink" 
                      runat="server"
                      text="Generate Trace Write" />
      <asp:LinkButton id="WarnLink"
                      runat="server"
                      text="Generate Trace Warn" />
        <br /><br />
    </div>
    </form>
</body>
</html>

Open in new window

0
 
LVL 40
ID: 39852628
The Trace and Debug objects are designed for debugging purpose and do not always behave as other objects, specially when you use them with exceptions objects.

That is why I told you to call ToString on your exception object.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 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