Permission denied - Logging

1

I have implemented Logging of python into several Flask projects successfully. But when I tried to re-implement Logging in a project it gives the following error:IOError: [Errno 13] Permission denied .

To try to solve the problem I created the file and still the error continues. It is strange that this error occurs after using the same code for all previous projects.

The error is supposed to occur in the following code:

if __name__ == '__main__':
    import logging
    logging.basicConfig(filename='error.log', level=logging.WARNING)
    app.run()
    
asked by anonymous 20.10.2015 / 18:46

1 answer

0

This error, number 13 , is related to permissions. The process running your website is not authorized to create or modify the error.log file in the attempted directory.

As your example is from Flask and runs app.run() I can assume that the user is yourself because it is the development webserver built into Flask.

So in this case, most likely you're running your script from a development directory, created by you, with all the necessary permissions. The only conclusion I have is that the error.log file is not being created within this directory.

A simple attempt to make your code work is to be more explicit about the location of the file, passing the complete path.

Example, assuming you want error.log in the same directory as the script:

    
20.10.2015 / 22:58