TraceOutputOptions not honored

Discussion in 'ASP .Net' started by =?Utf-8?B?Y2hheg==?=, Aug 25, 2006.

  1. I would like my trace entries to have a timestamp so I figured I
    could set the properties on the trace listener to accomplish this but THAT
    that doesn't see to work .
    dim txtListener as System.Diagnostics.TextWriterTraceListener = new
    System.Diagnostics.TextWriterTraceListener(sw, "txt_listener")
    txtListener.TraceOutputOptions = TraceOptions.DateTime


    Log entries don't get any time info when written.

    Doc says that these options aren't available for EventLogTraceListener but
    there isn't anything restricting TextWriterTraceListener nor should there be
    ..



    Any ideas ?
    thanks
    =?Utf-8?B?Y2hheg==?=, Aug 25, 2006
    #1
    1. Advertising

  2. Hi,

    For the built-in TraceListener classes, EventLogTraceListener and
    WebPageTraceListener will not use TraceOutputOptions to output additional
    content. Following built-in TraceListener classes should honor
    TraceOutputOptions correctly:

    * DefaultTraceListener
    * TextWriterTraceListner
    * ConsoleTraceListener
    * DelimitedListTraceListener
    * XmlWriterTraceListener

    However, these additional trace data controlled by TraceOutputOptions will
    not be generated if you are directly calling Write() or WriteLine() method.
    For these Write* methods, if will output only the message you let them
    output, they will not add additional content such as DateTime.

    You can use following code snippet to test it:

    #Const TRACE = True
    Dim txtListener As System.Diagnostics.TextWriterTraceListener = New
    System.Diagnostics.TextWriterTraceListener(System.Console.Out,
    "txt_listener")
    txtListener.TraceOutputOptions = TraceOptions.DateTime
    System.Diagnostics.Trace.Listeners.Add(txtListener)
    System.Diagnostics.Trace.WriteLine("This message will not add
    DateTime.")
    System.Diagnostics.Trace.TraceError("This error message will add
    DateTime.")

    Since you're asking in ASP.NET newsgroup (and based on your previous post
    about WebPageTraceListener), I assume you're use System.Diagnostics.Trace
    from ASP.NET web application. As I mentioned above, WebPageTraceListner
    will not use TraceOutputOptions to output additional content. However, I
    think the output generated by ASP.NET TraceContext may have the date time
    information you required:

    Here's an explanation of the "Trace Information" section contents in the
    asp.net trace log:

    =========================
    Category

    A custom trace category that you specified as the first argument in a
    trace.Write (or trace.Warn) method call.

    Message

    A custom trace message that you specified as the second argument in a
    Trace.Write (or Trace.Warn) method call.

    From First (s)

    The time, in seconds, since the request processing was started (a running
    total).

    From Last (s)

    The time, in seconds, since the last message was displayed. This column is
    especially helpful for seeing how long individual operations are taking.
    =========================

    Hope this helps. Please feel free to post here if anything is unclear.

    Sincerely,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Aug 28, 2006
    #2
    1. Advertising

  3. It wasn't clear or even mentioned in the documentation that the traceOptions
    are only available when calling traceError,warn or info . Additionally ,
    looking at the output I do get with Trace.TraceInfo with DateTime set, it is
    not formatted as I would like.
    ... so it's nice to have all these features but they aren't very useable
    so I suppose we will just write our own .

    thanks anyway

    "Walter Wang [MSFT]" wrote:

    > Hi,
    >
    > For the built-in TraceListener classes, EventLogTraceListener and
    > WebPageTraceListener will not use TraceOutputOptions to output additional
    > content. Following built-in TraceListener classes should honor
    > TraceOutputOptions correctly:
    >
    > * DefaultTraceListener
    > * TextWriterTraceListner
    > * ConsoleTraceListener
    > * DelimitedListTraceListener
    > * XmlWriterTraceListener
    >
    > However, these additional trace data controlled by TraceOutputOptions will
    > not be generated if you are directly calling Write() or WriteLine() method.
    > For these Write* methods, if will output only the message you let them
    > output, they will not add additional content such as DateTime.
    >
    > You can use following code snippet to test it:
    >
    > #Const TRACE = True
    > Dim txtListener As System.Diagnostics.TextWriterTraceListener = New
    > System.Diagnostics.TextWriterTraceListener(System.Console.Out,
    > "txt_listener")
    > txtListener.TraceOutputOptions = TraceOptions.DateTime
    > System.Diagnostics.Trace.Listeners.Add(txtListener)
    > System.Diagnostics.Trace.WriteLine("This message will not add
    > DateTime.")
    > System.Diagnostics.Trace.TraceError("This error message will add
    > DateTime.")
    >
    > Since you're asking in ASP.NET newsgroup (and based on your previous post
    > about WebPageTraceListener), I assume you're use System.Diagnostics.Trace
    > from ASP.NET web application. As I mentioned above, WebPageTraceListner
    > will not use TraceOutputOptions to output additional content. However, I
    > think the output generated by ASP.NET TraceContext may have the date time
    > information you required:
    >
    > Here's an explanation of the "Trace Information" section contents in the
    > asp.net trace log:
    >
    > =========================
    > Category
    >
    > A custom trace category that you specified as the first argument in a
    > trace.Write (or trace.Warn) method call.
    >
    > Message
    >
    > A custom trace message that you specified as the second argument in a
    > Trace.Write (or Trace.Warn) method call.
    >
    > From First (s)
    >
    > The time, in seconds, since the request processing was started (a running
    > total).
    >
    > From Last (s)
    >
    > The time, in seconds, since the last message was displayed. This column is
    > especially helpful for seeing how long individual operations are taking.
    > =========================
    >
    > Hope this helps. Please feel free to post here if anything is unclear.
    >
    > Sincerely,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    =?Utf-8?B?Y2hheg==?=, Aug 28, 2006
    #3
  4. I understand your concerns about the documentation, please feel free to
    give your feedback on the MSDN online documentation.

    In the meanwhile, if you need help on how to create your own TraceListener,
    please don't hesitate to let us know.

    Thank you for using MSDN Managed Newsgroup service!


    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], Aug 29, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pål Andreassen

    NTFS rights not honored

    Pål Andreassen, Dec 16, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    396
    Kevin Spencer
    Dec 16, 2003
  2. Richard Thoms
    Replies:
    6
    Views:
    4,912
    Richard Thoms
    Dec 2, 2005
  3. Pål Andreassen

    NTFS rights not honored

    Pål Andreassen, Dec 16, 2003, in forum: ASP .Net Security
    Replies:
    4
    Views:
    130
    Norman Rasmussen
    Dec 17, 2003
  4. RichardOnRails
    Replies:
    2
    Views:
    95
    RichardOnRails
    Nov 6, 2008
  5. Richard Lionheart
    Replies:
    8
    Views:
    124
    Thomas 'PointedEars' Lahn
    Mar 16, 2006
Loading...

Share This Page