This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients vinay.sajip, vstinner
Date 2021-10-07.09:47:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
One way to disable logging in a configuration file is to use /dev/null as the filename for logs. It is fine to use that with FileHandler.

The problem is when TimedRotatingFileHandler is used. When Python decides to rotate the "file", it calls os.rename() on /dev/null *device* and create a new /dev/null *file* which will be quickly filled by all applications on the system writing into /dev/null.

The problem is only possible if the process is allowed to rename the device /dev/null. For example, a regular user gets a permission error.

I see different options:

* TimedRotatingFileHandler should disable rotation if it detects that the file is a device (not a regular file)
* logging should switch to NullHandler if filename is equal to os.path.devnull.

I guess that the problem is the same if the filename points to a socket or a named pipe.

RotatingFileHandler may also be affected, I didn't check.

... I'm quite sure that I had the same issue with Twisted years ago, but I don't recall the details :-) Twisted didn't use the logging module if I recall correctly.

RHEL downstream issue:
Date User Action Args
2021-10-07 09:47:34vstinnersetrecipients: + vstinner, vinay.sajip
2021-10-07 09:47:34vstinnersetmessageid: <>
2021-10-07 09:47:34vstinnerlinkissue45401 messages
2021-10-07 09:47:34vstinnercreate