54π
You do not have path to a log file for some reason (/Users/deon/Documents/PyCharmProjects/Developments/deonproject/log). Make sure that all directories exist (if no, create them) and create an empty debug.log
log file (just in case).
What happens is there is some problem with your code happening. Handler catches this error to save it to your log file so that you can analyze it. However, the path to log file it is trying to open does not exist. Thus, exception occures during handling of another exception.
5π
I also faced the same issue, in my case the permissions of the logging file was not right.
so i changed the permissions to read and write to all user with the cmd
sudo chmod a+rwx debug.log
- [Django]-PyMongo vs MongoEngine for Django
- [Django]-Atomic increment of a counter in django
- [Django]-What is the purpose of adding to INSTALLED_APPS in Django?
2π
In case someone get it useful: In my case the error was triggered by a permissions issue. Once i change permissions and let app user write in folder this was solved.
- [Django]-Django REST framework: non-model serializer
- [Django]-ModuleNotFoundError: No module named 'grp' on windows
- [Django]-How to suppress the deprecation warnings in Django?
2π
In my Django project, I implemented some logic that would handle a situation like this:
we can declare some log-path, and if it doesnβt exist we can create the path:
# LOGGING
LOG_DIR = os.path.join(BASE_DIR, 'log')
LOG_FILE = '/api.log'
LOG_PATH = LOG_DIR + LOG_FILE
if not os.path.exists(LOG_DIR):
os.mkdir(LOG_DIR)
if not os.path.exists(LOG_PATH):
f = open(LOG_PATH, 'a').close() #create empty log file
else:
f = open(LOG_PATH,"w").close() #clear log file
Then in our Logging dict we can add the following to our "file" section of the handlers
LOGGING = {
...
'handlers': {
'file': {
...
'filename': LOG_PATH,
...
},
'console': {
...
}
},
}
- [Django]-Django REST framework β limited queryset for nested ModelSerializer?
- [Django]-PIL /JPEG Library: "decoder jpeg not available"
- [Django]-What is the easiest way to clear a database from the CLI with manage.py in Django?
0π
- Check whether log file exist in
/Users/deon/Documents/PyCharmProjects/Developments/deonproject/log/debug.log
location. - Check these location have proper write permission
In my case the ransomware protection was turned on and it preventing it from permission issue - Open the Code editor RUN AS ADMINISTRATOR mode
- [Django]-Programmatically create a django group with permissions
- [Django]-Get user information in django templates
- [Django]-Django nested transactions β βwith transaction.atomic()β β Seeking Clarification
0π
your log path does not exist.
Make sure this path exists
'/Users/deon/Documents/PyCharmProjects/Developments/deonproject/log/debug.log'
- [Django]-Django how to pass custom variables to context to use in custom admin template?
- [Django]-Django β how to specify a database for a model?
- [Django]-Serializing Foreign Key objects in Django
0π
In my case it was due to permission denied as django commands were executed as not owner of the logger files
- [Django]-Django order_by query set, ascending and descending
- [Django]-How to add class, id, placeholder attributes to a field in django model forms
- [Django]-How do I unit test django urls?
0π
For example if your handler is configured as
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "console",
},
"file": {
"level": "INFO",
"class": "logging.FileHandler",
"formatter": "file",
"filename": "logs/jirate.log",<-----
},
"django.server": DEFAULT_LOGGING["handlers"]["django.server"],
},
ensure that you have the folder logs created in the same level as your manage.py. Django will automatically create the jirate.log file
- [Django]-How to access request body when using Django Rest Framework and avoid getting RawPostDataException
- [Django]-How to work around lack of support for foreign keys across databases in Django
- [Django]-How can I programmatically authenticate a user in Django?
0π
This error can be caused if you havenβt created the folder of logs file
- Go to the setting.py file and check the path of your logs file
- Follow the path and create the folder
- [Django]-Difference between django-redis-cache and django-redis for redis caching with Django?
- [Django]-Django model one foreign key to many tables
- [Django]-In Django models.py, what's the difference between default, null, and blank?