Say I have a WCF app hosted in IIS. And in that app I run this line of code:
Console.WriteLine("Testing, testing 1 2 3");
Where will that be written to? Or is it ignored and just lost?
Is there someway to capture it when needed?
But when we host the service using console application and we want to consuming from client we need to keep service running manually. The service hosted using IIS will support only http protocol. Where as the service running or hosted in console application will also support TCP protocol
Whenever WCF service is hosted at IIS, the execution of the service will be under the control of IIS Whenever service is hosted with in console applications we should be always running as long as any client is consuming that service
That is controlled by the project's output type. (Properties -> Application -> Output Type). Console Application will get you a console window which will visualize and receive input from the window into the Error, In, and Out streams in System.Console.
The cache is fairly easy to configure using the user interface feature in the new IIS administration tool. From the Start menu, click Administrative Tools, and then click Internet Information Services (IIS) Manager. In the tree view on the left side, find your application. Select the Output Caching menu item.
Nowhere. More specifically:
NullStream
, which is defined as "A Stream with no backing store.". All the methods do nothing or return nothing. It is an internal class toStream
. The following code is taken from Microsoft's source code.Basically, when one of the
Console
write methods is call the first time, a call is made to the Windows API functionGetStdHandle
for "standard output". If no handle is returned aNullStream
is created and used.
quoted from here: https://stackoverflow.com/a/2075892/12744
actually, the same answer goes to on to address the second part of your question too:
To actually redirect Console output, regardless of the project type, use
Console.SetOut(New System.IO.StreamWriter("C:\ConsoleOutput.txt")),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With