The problem occur in a WPF application. The console output redirected is only partial (it is missing many lines). A console application is the reference output where all lines are there.
This is my code to redirect in my WPF app:
Outputter = new StreamWriter(@"C:\temp\test.txt");
Console.SetOut(Outputter);
Console.SetError(Outputter);
The code that we want to have its output use a C++ library and part of its output seems to not being redirected. Why and how to ensure that everything would be redirected?
Note: If I do like this accepted answer, then everything is redirected properly in a file. The problem here is we don't want a file. We want to redirect directly in a string without a file.
Note: I cannot include the C++ code which is a commercial product.
Sample of output with redirection (WPF app). The ouput is partial compared to console app:
Started
Adding variables ...
Adding constraints ...
Adding objectives ...
Model built, starting optimization ...
x[1,1] = 1
Sample Output when the application is a console application (it misses some lines at the end due to my screen capture):