I am trying to diagnose some mysterious Internal Server Errors, so I added logging to the flask app. After digging through many explanations, I found this answer which I am using below, along with the suggestion to put everything inside a @app.before_first_request
decorator.
Locally this works as expected and werkzeuglog.log
contains exactly what is printed to the screen.
But on the server:
- The log file is created.
- Nothing is written to it.
- No errors are thrown, at least not to the user
@app.before_first_request def initialize(): logger = logging.getLogger('werkzeug') logger.setLevel(logging.DEBUG) handler = logging.FileHandler('werkzeuglog.log') logger.addHandler(handler) if __name__ == '__main__': #run app app.run( host="0.0.0.0", port=int("80"), debug=False )
Am I doing something wrong or is this some server issue that is beyond my scope? Gentle answers appreciated!
EDIT:
Some context: An internal server error is caused when the user uploads a file and I am trying to figure out what's going wrong using the log.
I don't think it can be an issue with permissions since the script definitely creates the file. I checked that the disk is not full.
EDIT 2
I reran the run.fcgi file which starts the WSGI Server. Now the manual entries to the log file via logger.info('blah blah')
show up but not the others i.e. GET
POST
etc.
I don't have access to /var/log/nginx
. It's a student-volunteer run server so I would like to give them as much info as I can. But this is all I have so far.