From 1305b4f5a60ef72648e1c309097847345d62f3b4 Mon Sep 17 00:00:00 2001 From: kuizhiqing Date: Mon, 8 Nov 2021 16:57:25 +0800 Subject: [PATCH] avoid setting logging.basicConfig (#37031) --- python/paddle/distributed/fleet/elastic/manager.py | 7 ++++++- .../fleet/parameter_server/pslib/optimizer_factory.py | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/python/paddle/distributed/fleet/elastic/manager.py b/python/paddle/distributed/fleet/elastic/manager.py index 4e8853780f4..2a344e92765 100644 --- a/python/paddle/distributed/fleet/elastic/manager.py +++ b/python/paddle/distributed/fleet/elastic/manager.py @@ -20,8 +20,13 @@ import logging import signal import random -logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO').upper()) logger = logging.getLogger("ELASTIC") +logger.setLevel(logging.INFO) +formatter = logging.Formatter( + fmt='%(name)s %(levelname)s %(asctime)s %(message)s') +ch = logging.StreamHandler() +ch.setFormatter(formatter) +logger.addHandler(ch) ELASTIC_EXIT_CODE = 101 diff --git a/python/paddle/fluid/incubate/fleet/parameter_server/pslib/optimizer_factory.py b/python/paddle/fluid/incubate/fleet/parameter_server/pslib/optimizer_factory.py index 56d47621089..61630d77692 100644 --- a/python/paddle/fluid/incubate/fleet/parameter_server/pslib/optimizer_factory.py +++ b/python/paddle/fluid/incubate/fleet/parameter_server/pslib/optimizer_factory.py @@ -42,9 +42,12 @@ FLEET_GLOBAL_DICT = { "scale_sparse_grad": None, } -logging.basicConfig( - format='%(asctime)s - %(levelname)s - %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) +formatter = logging.Formatter(fmt='%(asctime)s - %(levelname)s - %(message)s') +ch = logging.StreamHandler() +ch.setFormatter(formatter) +logger.addHandler(ch) class DistributedOptimizerImplBase(object): -- GitLab