Hi, IMO logging should be inexpensive and as real-time as possible, hence buffering, locking, thread switching are to be avoided. I tend to open-append-close for each individual log message, since the last message before the app dies is probably the one you want to catch most of all. The good news is File.AppendAllText() is a static and thread-safe method that does exactly that: open-append-close without unnecessary hassle. It does perform security checks over and over, so you'd better log to a local file without special security issues. BTW: if you want to add an option to e-mail your log file from within the app, you really need to copy it first, otherwise mailing it and continuing to log would interfere... :)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets