Where will Console.writeline write to in a Windows Service application?


  • I have a windows service application with many Console.writeline() statements.

    Since it is running at background, I wonder where do all the output of Console.writeline() go to? Please enlighten me.

    I promise to grade you. It is just that the system has some problems posting, replying and marking answer. Once it is Ok, I will deem my words.


    Monday, September 18, 2006 2:22 AM


  • In a Windows Service there is no Console so Console.Write* output is discarded. There are a number of alternatives:

    1. The System.Diagnostics.Trace class has a similar interface to the Console class so you could migrate your code quite easily to this. It can then be configured to output to a file.
    2. You can use the System.Diagnostics.EventLog class to write to the Event Log which you can then monitor using Event Viewer.
    3. You can use the third-party open-source log4net library which is very flexible.
    Monday, September 18, 2006 3:05 AM