I'm trying to figure out how to get logging working properly. Its works on my local machine but not here. I have the following in app.py under create_app:
# app.py in create_app():
# setup logging files
path = app.config['LOGGING_PATH']
os.makedirs(path, exist_ok=True)
info_fh = RotatingFileHandler(os.path.join(path, 'info.log'), maxBytes=10000000, backupCount=3)
info_fh.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)s: %(message)s '
'[in %(pathname)s:%(lineno)d]'
))
info_fh.setLevel(logging.INFO)
app.logger.addHandler(info_fh)
warning_fh = RotatingFileHandler(os.path.join(path, 'errors.log'), maxBytes=10000000, backupCount=3)
warning_fh.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)s: %(message)s '
'[in %(pathname)s:%(lineno)d]'
))
warning_fh.setLevel(logging.ERROR)
app.logger.addHandler(warning_fh)
I can see the directory and files have been created in the right location, but the files are empty. Some of the logging information (logging.error) shows in the server error log instead of my errors.log file, and the logging.info doesn't log to the info.log file or the server error log.