Skip to content

Commit 824c4ef

Browse files
authored
avoid setting logging.basicConfig (#37031) (#37530)
1 parent 89fb196 commit 824c4ef

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

python/paddle/distributed/fleet/elastic/manager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,13 @@
2020
import signal
2121
import random
2222

23-
logging.basicConfig(level=os.environ.get('LOGLEVEL', 'INFO').upper())
2423
logger = logging.getLogger("ELASTIC")
24+
logger.setLevel(logging.INFO)
25+
formatter = logging.Formatter(
26+
fmt='%(name)s %(levelname)s %(asctime)s %(message)s')
27+
ch = logging.StreamHandler()
28+
ch.setFormatter(formatter)
29+
logger.addHandler(ch)
2530

2631
ELASTIC_EXIT_CODE = 101
2732

python/paddle/fluid/incubate/fleet/parameter_server/pslib/optimizer_factory.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@
4242
"scale_sparse_grad": None,
4343
}
4444

45-
logging.basicConfig(
46-
format='%(asctime)s - %(levelname)s - %(message)s', level=logging.INFO)
4745
logger = logging.getLogger(__name__)
46+
logger.setLevel(logging.INFO)
47+
formatter = logging.Formatter(fmt='%(asctime)s - %(levelname)s - %(message)s')
48+
ch = logging.StreamHandler()
49+
ch.setFormatter(formatter)
50+
logger.addHandler(ch)
4851

4952

5053
class DistributedOptimizerImplBase(object):

0 commit comments

Comments
 (0)