if you constantly need to add data, opening and closing a stream will carry
overhead. flushing after you add data is a better idea, but you could also
flush when your program exits.
that way you won't interrupt your program to do file io.
or maybe you can use the windows event log. the advantage is that you get a
nice reporting tool for free: the windows event log viewer.
check out the System.Diagnostics.EventLog class. however, the event log is
meant for logging important application events or failures. if you want to
capture tons of debug data it is not appropriate..
or if you want to log data during or after a measurement of something, you
could also stream your data to a database e.g. SqlServer. that way, you could
use things like crystal reports for generating result reports.
or if you want to keep track of internal data flow in you program (nr of
actions per second etc) you could implement a performance counter that can be
watched with the performance viewer.
it really depends on what you want to do with the data.
kind regards,
Bruno.
"pi**********@hotmail.com" wrote:
Hi,
I'm quite sure this could start a lot of arguements :p.
If i am creating a log file that is constantly added to during the
lifetime of my program, is it best to have a permanent Streamwriter
object that i write to and then flush after each comment, or to spawn a
new one each time i need to add to the log? Or maybe there's some
magical medium i haven't heard of?
Forget the postcards, just post your answers here instead.
James.