-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: Logging
-
Environment:Windows, running as a service (mongod and mongos)
-
Fully Compatible
-
Windows
-
Server 2.7.5, Server 2.7.6, Security 2020-05-04, Security 2020-05-18, Security 2020-06-01, Security 2020-08-24, Security 2020-09-07, Security 2020-09-21
cout/stdout and cerr/stderr do not work when running as a Windows service
We use cout and cerr in assorted places in the code, and we use the C/C++ function dup2() to redirect file handles 1 and 2 (stdout and stderr) to the log file so that statements like "cout << "message" << endl;" will send text to the screen or to a log file if --logpath is set. This works fine in Windows when running in a console window.
It doesn't work when mongod.exe or mongos.exe is running as a service in Windows. Text sent to cout or cerr (or stdout or stderr) goes nowhere and does not appear in the log file.
The dup2() API does not return an error ... it just doesn't do what we want it to do.
This means that some output will not be logged when running as a Windows Service. We may need to audit the code to identify places where we are relying on redirection of standard file handles to log output and change them to use another mechanism (like log()).
- duplicates
-
SERVER-1693 no cout usage at all - have to specify one way or other
- Closed
-
SERVER-23170 Remove lingering uses of std::cout and associated iostreams
- Closed
- related to
-
SERVER-6778 printStackTrace does not work when running as a Windows Service
- Closed
-
SERVER-15884 mongod --version shouldn't print date, severity, log component
- Closed