.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> .NET Framework >> Post New QuestionBookmark and Share Subscribe to Forum

Can I redirect tracing to a file

Posted By: Jegan R     Posted Date: November 03, 2010    Points:2   Category :.NET Framework
Can I redirect tracing to a file?

Responses
Author: Jean Paul             
Posted Date: November 03, 2010     Points: 5   

You can set the trace listener as set in the following.

class Program
{
public class Sample
{

public static int Main(string[] args)
{
Stream myFile = File.Create("c:\\test.txt");

TextWriterTraceListener myTextListener = new
TextWriterTraceListener(myFile);
Trace.Listeners.Add(myTextListener);
Debug.Listeners.Add(myTextListener);

Trace.Write("Test trace output ");
Debug.Write("Test debug output ");


Trace.Flush();

return 0;
}
}
}

// Please mark as answer if it satisfies :)

Jean Paul http://jeanpaulva.com/


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend