On 2018-08-13 17:37, Keep Secret wrote:
#!/usr/bin/env python3 import logging
Here you're configuring the logger, setting the name of the logfile and the logging level, but not specifying the format, so it uses the default format:
logging.basicConfig(filename='example.log',level=logging.DEBUG)
Here you're configuring the logger again, this time specifying the format and the logging level, but not a path of a logging file, so it'll write to the console:
logging.basicConfig(format='%(asctime)s;%(levelname)s:%(message)s', level=logging.DEBUG)
The second configuration is overriding the first.
logging.debug('Message1) logging.info('Message2') logging.warning('Message3') DEBUG:root:Message1 INFO:root:Message2 WARNING:root:Message3 BUT if I remove logging.basicConfig(filename='example.log',level=logging.DEBUG) I get 2018-08-13 18:35:48,982;DEBUG:Message1 2018-08-13 18:35:48,982;INFO:Message2 2018-08-13 18:35:48,983;WARNING:Message3 Can someone please tell me what I am doing wrong? Thanks
-- https://mail.python.org/mailman/listinfo/python-list