Flask Development Logging

August 29, 2018

main.py

import logging
from flask import Flask

app.logger.setLevel(logging.DEBUG)
logging.basicConfig(level=logging.DEBUG)

@app.route('/')
def hello():
    app.logger.info('app.logger')
    logging.info('logging')
    print('print')

    return 'Hello World'  


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=8088, debug=True)
python main.py
 * Serving Flask app "main" (lazy loading)
 * Environment: production
   WARNING: Do not use the development server in a production environment.
   Use a production WSGI server instead.
 * Debug mode: on
INFO:werkzeug: * Running on http://127.0.0.1:8088/ (Press CTRL+C to quit)
INFO:werkzeug: * Restarting with stat
WARNING:werkzeug: * Debugger is active!
INFO:werkzeug: * Debugger PIN: ***-***-***
[2018-08-29 05:29:33,474] INFO in main: app.logger
INFO:flask.app:app.logger
INFO:root:logging
print
INFO:werkzeug:127.0.0.1 - - [29/Aug/2018 05:29:33] "GET / HTTP/1.1" 200 -
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.