[SERVER-46543] Incomplete support for logging to NUL on Windows Created: 02/Mar/20  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Logging
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Minor - P4
Reporter: Jeffrey Yemin Assignee: Backlog - Security Team
Resolution: Unresolved Votes: 0
Labels: move-sec
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Server Security
Participants:

 Description   

On Linux/Mac, server daemons support setting the log path to /dev/null via the log path:

> mongod --logpath /dev/null

The equivalent invocation fails on Windows:

> mongod --logpath NUL
Failed global initialization: FileRenameFailed Could not rename preexisting log file "C:\Projects\MongoDb\dist-test\bin\NUL" to "C:\Projects\MongoDb\dist-test\bin\NUL.2020-03-02T12-45-03"; run with --logappend or manually remove file: Cannot create a file when that file already exists

You can work around this by using log append:

> mongod --logappend --logpath NUL

One other small behavioral difference: on WIndows that invocation produces no output. But on OS X you get one line of output:

~$ mongod --logappend --logpath /dev/null
2020-03-02T09:11:33.735-0500 I  CONTROL  [main] ***** SERVER RESTARTED *****



 Comments   
Comment by Mark Benvenuto [ 02/Sep/20 ]

Moving back to triage to decide if we want to fix this in logv2.

Comment by Mark Benvenuto [ 02/Sep/20 ]

With logv2, mongod also fails to start with --logpath NUL unless --logappend is specified due file renaming.

The extraneous SERVER RESTARTED message is gone though.

Generated at Thu Feb 08 05:11:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.