Closed
Description
Is your feature request related to a problem? Please describe.
it's useful to remove the logging handlers when rank > 0, example code:
import logging
import torch.distributed as dist
from monai.apps.auto3dseg.auto_runner import logger
def mute_logger(_logger):
if _logger.hasHandlers():
for h in list(_logger.handlers):
_logger.removeHandler(h)
_logger.addHandler(logging.NullHandler())
logger.warning("logging start") # example of logging (all ranks)
if dist.is_available() and dist.is_initialized() and dist.get_rank() > 0:
mute_logger(logger)
logger.warning("logging end") # example of logging (only rank 0)
would be great to make it a generic utility in monai:
- adds the capability of 'unmute'
- adds the support of modifying any monai logger --
logging.getLogger("name")
- when starting a logger, provides an option of rank0 only?