Как получить вывод стандартной погрешности от службы Windows?

Используйте свой пользовательский класс в качестве параметра - например:

public class CustomData
{
    public string Input;
    public string Output;
}

...

CustomData data = new CustomData();
data.Input = "Something";
gameInstance.SendMessage("MyObjectName", "MyFunctionName", data);
//use data.Input inside MyFunctionName like a parameter
//change data.Output inside MyFunctionName
//use data.Output
Debug.Log(data.Output);
7
задан veefu 6 May 2009 в 18:05
поделиться

2 ответа

Can you try manually redirecting stderr?

    FILE* stderr_redirect = freopen( "C:/stderr.log", "w", stderr );

    // Code that writes to stderr

    fclose( stderr_redirect );

Edit:

There is no way to redirect stdout or stderr for a service other than to handle those streams inside your service yourself. Some services provide an option to redirect these messages to a file. You could either temporarily redirect these streams or add an option to your service to make it configurable next time you have a problem.

5
ответ дан 7 December 2019 в 01:25
поделиться

If you are modifying the code to the service, you could call SetStdHandle in your ServiceMain:

SetStdHandle(STD_ERROR_HANDLE, logFileHandle);
5
ответ дан 7 December 2019 в 01:25
поделиться
Другие вопросы по тегам:

Похожие вопросы: