From 824c4ef9bfcf44333ffab23d7f32f382a3dfc909 Mon Sep 17 00:00:00 2001 From: kuizhiqing Date: Thu, 25 Nov 2021 11:34:05 +0800 Subject: [PATCH] avoid setting logging.basicConfig (#37031) (#37530) --- 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 e2fb29c5439..758c61fce1e 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