In your case, it will be easier to avoid using basicConfig()
- just create a handler and add it programmatically (ensuring that the code is executed only once), for example:
root_logger= logging.getLogger() root_logger.setLevel(logging.DEBUG) # or whatever handler = logging.FileHandler('test.log', 'w', 'utf-8') # or whatever handler.setFormatter(logging.Formatter('%(name)s %(message)s')) # or whatever root_logger.addHandler(handler)
This is more or less what basicConfig()
.
source share