Jens Günther writes:
Hey there, while checking some logs I was realising that there is no log rotation and some of them piled up to 5GB over the past year(s). Does anybody know how to activate it (if it's possible) or ...
Ok, I found a clue and it's still open :-) https://github.com/maxking/docker-mailman/issues/535 -> does anybody have a different approach?
I find it hard to believe that lack of logrotate configuration didn't get fixed pretty quickly. More likely it's a probably with core: https://gitlab.com/mailman/mailman/-/issues/931 This is the patch which has WFM for quite a while. (It's the same new code as 931, but 931 doesn't show the code removed.) I'll try to get a MR submitted this week but it won't show up in a release for a while. Note this patch is against 3.3.6; I haven't checked if there are changes to logging.py since that release. diff --git a/src/mailman/core/logging.py b/src/mailman/core/logging.py index 04847b318..68506a165 100644 --- a/src/mailman/core/logging.py +++ b/src/mailman/core/logging.py @@ -113,14 +113,20 @@ def _init_logger(propagate, sub_name, log, logger_config): if propagate is None else propagate) # Set the logger's level. log.setLevel(as_log_level(logger_config.level)) - # Create a formatter for this logger, then a handler, and link the - # formatter to the handler. - formatter = logging.Formatter(fmt=log_format, datefmt=log_datefmt) - path_str = logger_config.path - path_abs = os.path.normpath(os.path.join(config.LOG_DIR, path_str)) - handler = ReopenableFileHandler(sub_name, path_abs) - _handlers[sub_name] = handler - handler.setFormatter(formatter) + # There are two alternative approaches to registering handlers described + # in https://gitlab.com/mailman/mailman/-/issues/931#note_1411199556. + # Both are more or less incompatible with the get_handler() utility + # defined below. + handler = _handlers.get(sub_name) + if handler is None: + # Create a formatter for this logger, then a handler, and link the + # formatter to the handler. + formatter = logging.Formatter(fmt=log_format, datefmt=log_datefmt) + path_str = logger_config.path + path_abs = os.path.normpath(os.path.join(config.LOG_DIR, path_str)) + handler = ReopenableFileHandler(sub_name, path_abs) + handler.setFormatter(formatter) + _handlers[sub_name] = handler log.addHandler(handler)