0

I'm using CefSharp.OffScreen (63.0.3) in my project.

This package sometimes prints messages to the console by calling Console.WriteLine(), there is a way to stop it by defining LogSeverity.Disable but they have an open issue of this bug (it's still printing).

I want, in my project, to catch any calls to Console.WriteLine() and decide whether to ignore it or print it. Is there is a way to do that?

• Edit:

Any prints that came from the external package start with "[" symbol, So I just need to catch any print and check if the string starting with "[" to know if I want to print it or not...

  • I am not flagging as a dupe yet. Perhaps this question/answer? https://stackoverflow.com/questions/11911660/redirect-console-writeline-from-windows-application-to-a-string – JayV Jun 20 '18 at 18:28
  • you could redirect the console output. – Daniel A. White Jun 20 '18 at 18:28
  • if you redirect, you'll redirect all. this can be a solution if there is no other part of the application generating any console output you need. "decide whether to ignore it or print it": yes, but then it's all or nothing. there is no "source" in redirection which could be used for filtering (except maybe for adventurous approaches involving the current call stack) – Cee McSharpface Jun 20 '18 at 18:40
  • If you start the console programm via Process, you can redirect all 3 I/O Streams. This is a baseline .NET Framework Process Function since 1.1 of the Framework (https://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx). The StreamReaders can then be polled. So I do not see why this remote operation framework would not allow it. – Christopher Jun 20 '18 at 18:44

0 Answers0