2

I was trying to follow the flask error handling tutorial - http://flask.pocoo.org/docs/errorhandling/#logging-to-a-file.

When I try to create the handler I am getting error

[Errno 13] Permission denied: '/var/www/FlaskTest/FlaskTest/store.log'

I just want to log some data to a file for further analysis. What is the easiest way to do this?

EDIT:

Adding some more info: I am running the web application through the wsgi packaging and serving through apache. I understand user roles and need to grant permission :

logfile = logging.FileHandler("/var/www/FlaskTest/FlaskTest/store.log")

As you see I have tried targeting the www directory, should I be targeting another directory? I also don't want to expose the application by giving it unnecessary permissions. Is there a simple way to write objects to a file for later analysis in flask?

3
  • 1
    show us some code please Commented Mar 19, 2014 at 19:20
  • 1
    This typically means that process running your flask application does not have the user permissions to create a new file in /var/www/FlaskTest/FlaskTest, or it does not have the permissions to write to the file /var/www/FlaskTest/FlaskTest/store.log. Commented Mar 19, 2014 at 19:21
  • ok turns out if I am using apache-wsgi I need to tell wsgi to make the changes as here - stackoverflow.com/questions/10566107/… Commented Mar 21, 2014 at 7:12

1 Answer 1

5

The code is (probably) fine. The error is about OS permissions. The app is running as a user that does not have write permissions to the directory. You need to fix this outside of Flask.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.