PRB: ATL Service Run from the IDE Doesn't Log Events to Console (199060)
The information in this article applies to:
- The Microsoft Active Template Library (ATL) 2.0, when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
- The Microsoft Active Template Library (ATL) 3.0, when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q199060 SYMPTOMS
Using the ATL COM AppWizard to generate an NT service may not produce code that behaves as expected. When the AppWizard-generated service is started as a local server, the message strings passed to CServiceModule::LogEvent() are not displayed to the console. When started as a service, the messages are logged into the applications' event log.
CAUSE
In the generated code CServiceModule::LogEvent() calls _putts() in to write the message to stdout, but stdout is not setup by default.
RESOLUTION
To remedy this behavior, the developer should do one of the following: -
Edit CServiceModule::Start() to initialize stdout as desired (that is, redirect it either to a console or to a file). The code to do this is in the More Information section below.
-
Replace _putts() with ATLTRACE().
-
Redirecting the output of the application to a file, in a console window. For example:
MyApp.exe > output.txt
-
In CServiceModule::LogEvent(), remove the "if" statement and _putts() statement, so that the output always goes to the application log file.
Modification Type: | Major | Last Reviewed: | 12/11/2003 |
---|
Keywords: | kbprb kbService KB199060 |
---|
|