diff --git a/mpsd-software-environment.py b/mpsd-software-environment.py index 0d4ca90d5ecdf7232cf3cd98935343effe6f01e0..73c61b9e7b0d801f56e3337345e6afb40faf5471 100755 --- a/mpsd-software-environment.py +++ b/mpsd-software-environment.py @@ -270,7 +270,12 @@ def set_up_logging(loglevel="warning", filename=None): shell_handler.setFormatter(shell_formatter) # use the log_level_numeric to decide how much logging is sent to shell shell_handler.setLevel(log_level_numeric) - logger.addHandler(shell_handler) + + # Here we set the handlers of the RootLogger to be just the one we want. + # The reason is that the logging module will add a <StreamHandler <stderr> + # (NOTSET)> handler if logging.info/logging.debug/... is used before we + # come across this line. And we do not want that additional handler. + logger.handlers = [shell_handler] # if filename provided, write log messages to that file, too. if filename: