[Answered ]-Python logger not working for django with apache

1๐Ÿ‘

I was stuck in the same issue once. What I found was a bit confusing to me, but it worked. The issue was with parameter

disable_existing_loggers: True,

Using this param to true, means you want to disable all the loggers and override it with existing django logger which you have defined. But, it does not do so automatically. You also need to redefine those loggers in the settings.py file and also their parents.

In my case, I did not have any such requirement. So rather than going from the pain of redefining all the logger I just changed the parameter and set it to false. And it worked.

disable_existing_loggers: False,

I hope this solves your issue. Permission checks can also be performed.

Additionaly, you can user Sentry to trace what is wrong with your code.

๐Ÿ‘คPriyesh

1๐Ÿ‘

I am couple of years late but anyways i faced similar issue and below is my comment

'filename': '/logs/django.log',

to

'filename': '/fillpath/logs/django.log',
or
BASE_DIR = 'django project path'
'filename': os.path.join(BASE_DIR, 'logs/django.log'),

Also in the views or wherever you want to log things

Below one works with django runserver but not with apache httpd

import logging
logme = logging.getLogger('__name__')

Make below change and it will work for apache/httpd

import logging
logme = logging.getLogger('seekers')
๐Ÿ‘คpkm

Leave a comment