Your (debug) log messages are suppressed by Flask, since you are not working in debug mode. If you set this parameter to True, your code will work.
app.run(debug=True)
Messages will now appear as expected.
BennyE$ python3 stackoverflow.py 2015-03-08 12:04:04,650 ERROR: firs test message... [in stackoverflow.py:31] * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) * Restarting with stat 2015-03-08 12:04:04,807 ERROR: firs test message... [in stackoverflow.py:31] -------------------------------------------------------------------------------- DEBUG in stackoverflow [stackoverflow.py:11]: second test message... -------------------------------------------------------------------------------- 2015-03-08 12:04:13,789 DEBUG: second test message... [in stackoverflow.py:11] 192.168.178.23 - - [08/Mar/2015 12:04:13] "GET / HTTP/1.1" 200 - -------------------------------------------------------------------------------- DEBUG in stackoverflow [stackoverflow.py:11]: second test message... -------------------------------------------------------------------------------- 2015-03-08 12:04:14,899 DEBUG: second test message... [in stackoverflow.py:11] 192.168.178.23 - - [08/Mar/2015 12:04:14] "GET / HTTP/1.1" 200 -
This is the result in the corresponding output file:
BennyE$ cat output.log 2015-03-08 11:58:22,226 ERROR: firs test message... [in stackoverflow.py:31] 2015-03-08 12:04:04,650 ERROR: firs test message... [in stackoverflow.py:31] 2015-03-08 12:04:04,807 ERROR: firs test message... [in stackoverflow.py:31] 2015-03-08 12:04:13,789 DEBUG: second test message... [in stackoverflow.py:11] 2015-03-08 12:04:14,899 DEBUG: second test message... [in stackoverflow.py:11]
BennyE_HH
source share