From 539a46ca9a5b75d6c9d27ccd90886efc260999ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 10 Feb 2016 16:58:33 +0100 Subject: [PATCH] core/log: do not attach multiple handlers to the same logger logging.getLogger when given the same name twice, will return the same object. Do not attach handler there every time, it will really open new file, leading to multiplicated log entries and depleting file descriptors. QubesOS/qubes-issues#1697 --- qubes/log.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qubes/log.py b/qubes/log.py index 8da8b12e..3b82a69f 100644 --- a/qubes/log.py +++ b/qubes/log.py @@ -125,6 +125,8 @@ def get_vm_logger(vmname): ''' logger = logging.getLogger('vm.' + vmname) + if logger.handlers: + return logger handler = logging.FileHandler( os.path.join(LOGPATH, 'vm-{}.log'.format(vmname))) handler.setFormatter(formatter_log)