skip to Main Content

I am running Flask 1.1.4 via Python 3.5.3, hosted via an Apache 2 server on Debian Stretch. I am attempting to log various messages from the program, using the python logging module. This works normally. However, if I restart the Apache server using sudo service apache2 restart, the Flask application errors out with PermissionError: [Errno 13] Permission denied: (log file name). Is this an issue anyone else has run into?

2

Answers


  1. Chosen as BEST ANSWER

    It turns out that there was a cron process that was editing the ownership of all files in my log folder to root. Once the program was restarted and needed to re-obtain the file reference, it was unable to do so.


  2. If it is not a permissions issue, this usually happens (happened to me a few times) if you are using a relative path for the log file.

    The current working directory for an app running with mod_wsgi is not the directory the the app is in. If you are using a relative path for the log file you can try to use absolute path instead.

    More info here: https://modwsgi.readthedocs.io/en/master/user-guides/application-issues.html#application-working-directory

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search