Debug.Write into a file ???

  • Thread starter Thread starter Andy Fish
  • Start date Start date
A

Andy Fish

Hi,

I am wanting to put some simple logging into my .net app. The basic features
will be that errors get logged to a file and that there will be a
configuration flag to enable more detailed logging. It must be simple to
enable the detailed output in the live application.

I have used Debug.Write() but this seems to come out only on the output
window in the IDE - is there a way of configuring this to go into a file? I
also saw there is Trace.Write() but it seems that for this I have to
implement my own listener application to listen to the trace output.

Is it easy to make either of these do what I want or should I roll my own
logging code? I know that there is a port of log4j caled log4net but my app
is really not big enough to warrant this level of sophistication. At the
moment I am not after being able to have different levels of logging for
different components.

Thanks in advance for any advice

Andy
 
Andy said:
Hi,

I am wanting to put some simple logging into my .net app. The basic
features will be that errors get logged to a file and that there will be a
configuration flag to enable more detailed logging. It must be simple to
enable the detailed output in the live application.

I have used Debug.Write() but this seems to come out only on the output
window in the IDE - is there a way of configuring this to go into a file?
I also saw there is Trace.Write() but it seems that for this I have to
implement my own listener application to listen to the trace output.


Any .Net app can set up Trace.Listeners to handle logging/debug messages.

The great thing about it is a Listener can be many things.

It can be a text file -- yes -- but, you can also write directly to the OS
Event log -- for example, you could write to the Windows Application Event
log -- OR, you can create your own Event type such as MyApp -- which can be
viewed from Event Viewer.

There's a great, cheap, e-book called 'Tracing and Logging in .NET' that is
available as a PDF from Amazon. I suggest you read it.
 
Back
Top