Because I don't have any Windows Server with IIS on which I can test functionality of the app I want to ask if this code below would work the way I intended - web app writes something to console and I need to save what is written in console to a specific file. I am testing it locally on my laptop with ISS Express installed by Visual Studio 2013.
Is IIS Express the same as IIS on Windows Server so I can use this piece of code below?
using (var consoleWriter = new StreamWriter(
new FileStream(_tempOutputFileName,
FileMode.Create, FileAccess.Write)))
{
Console.SetOut(consoleWriter);
//do some work here with output to console
}
var standardOutput =
new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true };
Console.SetOut(standardOutput);
Edit : I can't write to file directly because I need to catch what is written to console by 3rd party library I am using.