473,320 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

TraceOutputOptions not honored

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
Aug 25 '06 #1
3 3104
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 (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 28 '06 #2
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 (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 28 '06 #3
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 (wa****@online.microsoft.com, 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.

Aug 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Pål Andreassen | last post by:
Running Windows 2003 Server Framework 1.1 A site is configured to use integrated security (in IIS 6) Windows autentication and user impersonation in web.config <identity impersonate="true" />...
8
by: Richard Lionheart | last post by:
Hi All, The test page follows. Clicking the button brings up a message box announcing that the browser had entered the function intended to populate the text area. Dismissing the message box...
6
by: Lloyd Dupont | last post by:
Before printing I create an instance of PrintDocument as Follow (beware, pseudo code) //============================== PrinterResolution pr = new PrinterResolution(); pr.X= 600; pr.Y= 600;...
2
by: Craig Taylor | last post by:
I've seen other referances to this bug in IE when researching the problem but haven't seen any solutions. Apparently IE does not honor setAttribute of colspan when building a table. Does anyone...
6
by: Summercool | last post by:
I just found that for a table, the margin for <trand <tdare not honored, but the padding is... is this a widely known fact? why make this an exception for margin, i wonder. margin not...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.