I have a problem with a nhibernate race condition in my webapp.
I am aware of this happening when using older versions of log4net (should be fixed in 1.2.10), althou
The problem with solution that @APW provided is that by default, StreamWriter is not thread safe. Check it here: https://msdn.microsoft.com/en-us/library/system.io.streamwriter(v=vs.110).aspx
By passing "new StreamWriter" to Console.Set* you are passing non-thread safe instance. So I think it's a matter of time to see similar error again.
Correct way would be using TextWriter.Synchronized method to wrap unsafe Stream.Null.
using System.IO;
...
var nullStream = TextWriter.Synchronized(TextWriter.Null);
Console.SetOut(nullStream);
Console.SetError(nullStream);
UPD: Please ignore this. I have found that Console.SetOut wrapping any stream into TextWriter.Synchronized(...). Proof.