Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #27049

    We’re having an issue in a deployed environment that we cannot debug. The issue is that a page is being rendered blank and we’re trying to figure out why. The application were having trouble with is a WCF Windows service with a reference to a registered PD4ML, version 385 for .NET 2.0 (pd4ml.prof.dotnet20.385). We’ve turned on PD4ML.enableDebugInfo() and from what we understand, it writes to the console when it logs, so we’ve tried hooking into it using the code below, but no logs are showing. We’ve also checked the event viewer, but nothing is written there either. We have, however, been successful with debugging locally using a console application.

    Could someone please help us understand where we can find the debug information in a deployed environment for a Windows service?

    <br /> Console.SetError(New System.IO.StreamWriter("C:ConsoleErrorOutput.txt"))<br /> Console.SetOut(New System.IO.StreamWriter("C:ConsoleOutput.txt"))<br />

    #29839

    I’ve forwarded the question to our .NET team. I’ll let you know as soon as we have new info.

    #29840

    @PD4ML wrote:

    I’ve forwarded the question to our .NET team. I’ll let you know as soon as we have new info.

    Much appreciated! However, we figured out it out. See below.

    1. In the OnStart function of Windows Service Host class, add the following code:
    <br /> Console.SetError(New System.IO.StreamWriter("[filename]")<br />

    2. Then in the OnStop function, add the following code:
    <br /> Console.Error.Close()<br />

    I’m sure there are other ways to do this such as creating your own custom System.Diagnostics listener, but this way works too. One thing to note is that you will need to stop the service in order to see the logs that were written.

    #29841

    Thank you for sharing the info!

    WCF supports a number of service initialization methods: http://blogs.msdn.com/b/wenlong/archive/2006/01/11/511514.aspx

    A straightforward way would be to redirect the console by WCF service start in AppInitialize() (and instantly test it with Console.Error.WriteLine() if needed)

    Note: if AutoFlush is not disabled, you may see the first log output only after an output buffer is full.

Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘Troubleshooting’ is closed to new topics and replies.