Debug.Print not printing in a C# service

Posted on 2011-05-11
Last Modified: 2012-08-13
I include a "Debug.Print (strMessage)" in my Windows Service program.  I can't find the output anywhere, I looked in the output window, immediate window, etc.  Is this feature not supported in a Windows Service?  Do I need to write it to a windows system log?  If there is a way, I would like to write it to one of the windows that I can just view as the processing occurs (rather than lookup in a log file).

Question by:compuzak1
    LVL 10

    Expert Comment


    Author Comment

    Thanks, I will try this if I don't get a response that just uses the Visual Studio system.  

    Do you know if you can use Debug.Print in a Windows Service while debugging?  I doubt it since I have to trick the program to acutally enter debug mode before the service actually starts (I call my main processing function).
    LVL 10

    Accepted Solution

    A windows service is not intended for user interaction. You don't run it through Visual Studio, you run it by installing the service to a windows system and then running it. Thus, for debugging/tracing, you can use different options such as writing to an event log, writing to a text file, etc., but IDE output is not an option.

    The link I provided kind of skirts around this a bit, but regardless, keep in mind that Windows Service Apps are not intended for user interaction. If that is the case, you need to go with a console app.

    Speaking of which, if you really really want to have a console, I've seen tons of examples on how to run a windows service as a console app. Never done it myself, but if you just have to have it, you can also consider that route. I'm not sure of the pros/cons of it though.


    - Anthony

    Author Closing Comment

    Thanks for your input.  This is what I thought.

    I do not need a console, I am only using the debug.print for testing purposes, it will not be included in the final version.  It just saves time in debugging if you see the values on the screen rather than go to a log file.  

    Thanks for your help

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now