473,513 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trace to file just doesn't seem to be working

2 New Member
Hi guys,

I'm trying to get to grips with the System.Diagnostics.Trace class, and I just can't get any output to go to file. Whenever I use a TextWriterTraceListener, all I ever get is an empty file. For example, the following simple app:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Diagnostics;
  3.  
  4. namespace Test
  5. {
  6.     class Test
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.         Trace.Listeners.Add(new ConsoleTraceListener());
  11.         Trace.Listeners.Add(new TextWriterTraceListener("trace.txt"));
  12.         Trace.WriteLine("blah");
  13.         }
  14.     }
  15. }
correctly puts "blah" out to the screen, and creates a file called "trace.txt", but the file is empty.

I've tried both from VS 2005 and just building on the command line, and I've tried with both .NET 2.0 and going back to 1.1. I've tried giving Everyone full permissions on the directory in question. Anyone have any ideas?

Cheers,

- Chris
Feb 21 '07 #1
1 985
ThePants999
2 New Member
Aha, I wasn't flushing it. Never mind!
Feb 22 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
9667
by: Champika Nirosh | last post by:
Hi, What is the different between System.Diagnostic.Trace and LogforNet.. if Trace is there to track error why this open source library is there.. Please clarify.. Nirosh.
1
1511
by: H Branyan | last post by:
In the Application_OnStart event in global.asax, my code calls an AlertService which creates a System.Timers.Timer() object. So this service doesn't actually run in conjunction with a specific...
9
4376
by: Joe Rattz | last post by:
I can't seem to get to trace.axd. I have turned tracing on in web.config. Here is how I currently have i configured: <trace enabled="true" requestLimit="10" pageOutput="false"...
45
3005
by: Arno R | last post by:
Hi all, I am about to distribute an A97-runtime app. which will be used on a LAN by approx. 30 users. The network is pretty good, but there are a few managers who have wireless laptops... Of...
5
23120
by: Brett Romero | last post by:
I have this in an app.config file: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.diagnostics> <trace autoflush="true" indentsize="2"> <listeners> <add name="myListener"...
4
2906
by: kyosohma | last post by:
Hi All, Can Python parse a trace file created with MS SQL's profiler? There are a few thousand lines in the trace file and I need to find the insert statements and the stored procedures....
3
7826
by: Simon | last post by:
Hi all, I'm trying to use the Trace class to log messages to a simple text file. I need to be able to provide a custom filename to be used. I've created a TextWriterTraceListener and added it to...
2
2574
by: tshad | last post by:
I have a page with Trace.Warns statements in my Page_Load and functions that it calls, but it doesn't seem to work in a class that is defined on the same page. I am writing this in C# I am...
4
2813
by: Chris8Boyd | last post by:
I am embedding Python in a MSVC++ (2005) application. The application creates some environment and then launches a Python script that will call some functions exported from the MSVC++ application....
0
7265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7541
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5098
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.