Majid Rajabi
Majid Rajabi

Reputation: 1765

ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/var/log/mysite/mysite.log'

The production server is running right now and I just run the python manage.py shell in the VPS terminal but it says :

Traceback (most recent call last):
  File "/usr/lib/python3.5/logging/config.py", line 558, in configure
handler = self.configure_handler(handlers[name])
  File "/usr/lib/python3.5/logging/config.py", line 731, in 
configure_handler
    result = factory(**kwargs)
  File "/usr/lib/python3.5/logging/handlers.py", line 150, in __init__
    BaseRotatingHandler.__init__(self, filename, mode, encoding, 
delay)
  File "/usr/lib/python3.5/logging/handlers.py", line 57, in __init__
    logging.FileHandler.__init__(self, filename, mode, encoding, delay)
  File "/usr/lib/python3.5/logging/__init__.py", line 1008, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python3.5/logging/__init__.py", line 1037, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
PermissionError: [Errno 13] Permission denied: 
'/var/log/mysite/mysite.log'

what can I do?

Upvotes: 1

Views: 3083

Answers (1)

ddor254
ddor254

Reputation: 1628

you have 2 options: 1 - change the permissions of the file /var/log/mysite/mysite.log so other users can write to it. like chmod 666 /var/log/mysite/mysite.log

2 - run your shell script from root or the user that own /var/log/mysite/mysite.log

Upvotes: 2

Related Questions