Logging.basicconfig configuration logging to file A, and then using Logging.filehandler to generate records to file B logger
When using this logger log, both files A and B are logged simultaneously, and it feels like the mechanism is quite unexpected.
#-*-Coding:utf8-*-import logginglogging.basicconfig ( level=logging. DEBUG, format= ' [% (asctime) s][% (process) d:% (thread) d][% (levelname) s]% (message) s ', filename= "Main.log", filemode= ' A + ') _logger = Logging.getlogger (' aaa.log ') fh = logging. Filehandler (' Aaa.log ') fh.setlevel (logging. DEBUG) Formatter1 = logging. Formatter (' [% (asctime) s][% (process) d:% (thread) d][% (levelname) s]% (message) s ') Fh.setformatter (Formatter1) _ Logger.addhandler (FH) _logger.debug (' aaa ') _logger.debug (' BBB ')
[python]logging module logs duplicate issues after using Basicconfig