4

I have the flask app serving in waitress in windows, I have logger info

app = Flask(__name__)
logging.basicConfig(level=logging.ERROR)

@app.route('/run', methods=['POST'])
def RunFunction():
    …………codes...……..
    app.logger.info("Log 1: Starting App on Port: {}".format(LISTEN_PORT))
    …………...

If I run with flask, I get the logger info

if __name__ == '__main__':   
    app.run(debug=True,port=8080, threaded=True,use_reloader=False)

If I use in waitress

from waitress import serve
serve(app, host='0.0.0.0', threads=WAITRESS_THREADS, port=LISTEN_PORT)

I am not getting logger info in console

I tried

app = Flask(__name__)
logger = logging.getLogger('waitress')
logger.setLevel(logging.ERROR)

and logger codes as

logger.info("Log 1: Starting App on Port: {}".format(LISTEN_PORT))

This is not working

Also I tried

from paste.translogger import TransLogger 
serve(TransLogger(app, setup_console_handler=True), host='0.0.0.0', threads=WAITRESS_THREADS, port=LISTEN_PORT)

This also not working, may I know how to get the logger info in waitress

hanzgs
  • 1,498
  • 17
  • 44
  • How about: ```python app = Flask(__name__) logger = logging.getLogger('waitress') logger.setLevel(logging.INFO) ``` followed by: ```python logger.info("Log 1: Starting App on Port: {}".format(LISTEN_PORT)) ``` – Harm Apr 30 '21 at 11:58
  • If you set the level to `ERROR`, `INFO` log lines will not show up. – Klaus D. Jan 19 '22 at 09:05

0 Answers0