I'm running code on a microcontroller with .NET Micro Framework, and I want my debug output to write to a text file. How does this work?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
The most flexible solution for using a out-of-the-box tracing is to make an application configuration file that will define trace listeners.
Then, in your application, whenever you want to log something, just do:
But the power of the TraceListener class lies into its granularity. You can chose between Error, Info and Warning levels and define different log file for whatever level you need to trace. Using configuration files makes it also easier to disable tracing in your application because you don't need to recompile your application.
For more informations on tracing system, check this MSDN article.
Use Trace. It is designed to do what you need.
Ekk is right about Trace being a better design, however that doesn't answer the question, which would be fine in the absence of a direct solution. The OP or someone may have inherited a code base which uses Debug throughout, and Trace may not be desirable at the time.
I found this solution [http://bytes.com/topic/c-sharp/answers/273066-redirect-output-debug-writeline] :
You will have to do something like this:
Taken from here.
Another related question