views:

63

answers:

2

Why do I use Tracing for logging exception in TextFile? What is the advantage of using trace over simple log while I am logging in text file.

+1  A: 

The advantage of using built-in Tracing in .NET is that you can easily switch between listeners and by simply modifying your config file switch from tracing to a text file into the event log of the machine.

Darin Dimitrov
+2  A: 

Darin lists one important reason. Another is that you can call Trace methods from any thread. It sorts out the marshalling for you, making it much less intrusive than roll-your-own-mess. A third reason is quality of implementation; the Microsoft Trace library is in its second major revision and is thoroughly tested production quality code. Fourth, TraceSwitch supplements the built in Trace class, providing a way to control the level of trace detail recorded, using only config file settings.

Peter Wone