Solved

mailing myself the trace information

Posted on 2014-02-10
9
234 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
Industry Leaders: 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

Independent Software Vendors: 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!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

719 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