console.setout

How can I ensure atomicity of a get-and-set operation to redirect Console.Out for logging console output?

I need to intercept the console output stream(s) in order to capture it for a log but still pass things through to the original stream so the application works properly. This obviously means storing the original Console.Out TextWriter before changing it with Console.SetOut(new MyTextWriterClass(originalOut)). I assume the individual op...

Console.SetOut to StreamWriter, write to textfile constantly

I'm using the Console.SetOut method to write all my Console.Out.WriteLines to a file, and this works. The only problem is that it only writes everything to the textfile when I close my application instead of it writing whenever a Console.Out.WriteLine happens. Any ideas on how I can realise this? How I do it: Before Application.Run(); ...