Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6777

Eliminate all direct use of cout/stdout and cerr/stderr

    • 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()).

            Assignee:
            adam.cooper@mongodb.com Adam Cooper (Inactive)
            Reporter:
            tad Tad Marshall
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: