Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
flask logging test
import logging
from logging.handlers import TimedRotatingFileHandler
from flask import Flask
# f_formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(filename)s - %(message)s')
fmt = '%(asctime)s - %(levelname)s - %(filename)s - %(message)s'
f_handler = TimedRotatingFileHandler('app.log', when='s', interval=1)
# filename='app.log',
handlers=[f_handler, ]
logger = logging.getLogger(__name__)
app = Flask(__name__)
def index():"hello world")
print("pprint text")
logger.debug('This is a debug message')'This is an info message')
logger.warning('This is a warning message')
logger.error('This is an error message')
logger.critical('This is a critical message')
return '123'
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment