Answer the question
In order to leave comments, you need to log in
How to make the necessary getLogging registered?
Hello.
I have multiple getLogger. Namely: getLogger('a'), getLogger('b'), getLogger('c'), getLogger('d').
How can I make it so that only getLogger('b') and getLogger('c') are logged in now?
logging.basicConfig(level=logging.DEBUG , filename=path_logging, format='%(lineno)d :: %(name)s :: %(levelname)s :: %(module)s :: %(asctime)s :: %(message)s')
logger = logging.getLogger('a')
logger_2 = logging.getLogger('b')
logger_3 = logging.getLogger('c')
logger_4 = logging.getLogger('d')
Answer the question
In order to leave comments, you need to log in
do not through basicConfig, but write your own get_logger function in which we add the necessary handlers. Then we get what we need using our custom function.
For example:
def get_logger(logger_name: str) -> logging.Logger:
logger = logging.getLogger(logger_name)
logger.setLevel(logging.INFO)
logger.addHandler(get_console_handler())
logger.addHandler(get_file_handler())
logger.propagate = False
return logger
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question