I'm running this flask application to test logging. It's running fine on my local system, but if I run it on the apache server using mod_wsgi, it doesn't work. There is no errors, but, no foo.log is created.
I'm using python 3.5
The code looks like this:
from flask import Flask
import logging
from logging.handlers import RotatingFileHandler
app = Flask(__name__)
@app.route('/')
def foo():
app.logger.warning('A warning occurred (%d apples)', 42)
app.logger.error('An error occurred')
app.logger.info('Info')
return "foo"
if __name__ == '__main__':
handler = RotatingFileHandler('foo.log', maxBytes=10000, backupCount=1)
handler.setLevel(logging.INFO)
app.logger.addHandler(handler)
app.run(host='0.0.0.0')
the wsgi file looks like this:
#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")
from FlaskApp import app as application
application.secret_key = 'Add your secret key'