I have the following code to write to a file:
import logging
log=logging.getLogger('avails')
log_file = 'file.txt'
fh = logging.FileHandler(log_file)
fh.setLevel(logging.INFO)
log.addHandler(fh)
log.info('hello')
This will write the word "hello" to the file file.txt. However, I would like to format this, so it is written to the file as follows:
'format': '[%(asctime)s] %(filename)s:%(lineno)d@%(funcName)s [%(levelname)s] %(message)s'
How would I add this format in so it writes that way to the file?