How do I silence Console.Writeline?
I'm using a library that -- for whatever reason -- has decided to write warnings to Console.Writeline. This means it constantly clutters up my Results pane with its internal nonsense.
This is coming from somewhere deep inside this library. I cannot change it.
How do I somehow prevent it from writing anything to the results?
Comments
-
If you don't mind losing the output of any Console.Writes or Console.WriteLines in your linqpad script, then you can redirect the output to null, e.g.
Console.SetOut(TextWriter.Null);
-
This sounded wonderful, but it taught me that they must not being using Console.Writeline, because it didn't stop the messages.
How else could a library be writing to my results like this?
SQLite notice (27): delayed 25ms for lock/sharing conflict at line 46988 SQLite notice (27): delayed 25ms for lock/sharing conflict at line 46988 SQLite notice (27): delayed 25ms for lock/sharing conflict at line 46988 SQLite notice (27): delayed 25ms for lock/sharing conflict at line 46988
-
Here's the line from the SQLite source:
sqlite3_log(SQLITE_NOTICE, "delayed %dms for lock/sharing conflict at line %d", winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno );
I followed that method call, and it looks like it's just doing
printf
from the C code. -
Something else you can try is
Trace.Listeners.Clear();
-
That did it. Thank you.