Solved

mailing myself the trace information

Posted on 2014-02-10
9
229 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
[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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

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.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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