9
votes

I am trying to run Gunicorn, and I am running into an error (pasted below). At present it looks like Gunicorn or one of its dependencies is attempting to read settings.LOGGING, and the settings.py file does not appear to define a settings.LOGGING.

So I'd like to know what sort of literal or other code I can add so that Gunicorn + dependencies have what they think they need.

Code paste:

(socialenv)jonathan@li393-189:~/directory$ python manage.py run_gunicorn 0.0.0.
0:8000
2013-04-14 17:40:13 [26464] [INFO] Starting gunicorn 0.17.2
2013-04-14 17:40:13 [26464] [INFO] Listening at: http://0.0.0.0:8000 (26464)
2013-04-14 17:40:13 [26464] [INFO] Using worker: sync
2013-04-14 17:40:13 [26469] [INFO] Booting worker with pid: 26469
2013-04-14 17:40:13 [26469] [ERROR] Exception in worker process:
Traceback (most recent call last):
  File "/home/jonathan/socialenv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 485, in spawn_worker
    worker.init_process()
  File "/home/jonathan/socialenv/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_process
    self.wsgi = self.app.wsgi()
  File "/home/jonathan/socialenv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 103, in wsgi
    self.callable = self.load()
  File "/home/jonathan/socialenv/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 133, in load
    return mod.make_command_wsgi_application(self.admin_media_path)
  File "/home/jonathan/socialenv/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 113, in make_command_wsgi_application
    reload_django_settings()
  File "/home/jonathan/socialenv/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 109, in reload_django_settings
    logging_config_func(settings.LOGGING)
  File "/usr/lib/python2.7/logging/config.py", line 777, in dictConfig
    dictConfigClass(config).configure()
  File "/usr/lib/python2.7/logging/config.py", line 503, in configure
    raise ValueError("dictionary doesn't specify a version")
ValueError: dictionary doesn't specify a version
Traceback (most recent call last):
  File "/home/jonathan/socialenv/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 485, in spawn_worker
    worker.init_process()
  File "/home/jonathan/socialenv/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_process
    self.wsgi = self.app.wsgi()
  File "/home/jonathan/socialenv/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 103, in wsgi
    self.callable = self.load()
  File "/home/jonathan/socialenv/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 133, in load
    return mod.make_command_wsgi_application(self.admin_media_path)
  File "/home/jonathan/socialenv/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 113, in make_command_wsgi_application
    reload_django_settings()
  File "/home/jonathan/socialenv/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 109, in reload_django_settings
    logging_config_func(settings.LOGGING)
  File "/usr/lib/python2.7/logging/config.py", line 777, in dictConfig
    dictConfigClass(config).configure()
  File "/usr/lib/python2.7/logging/config.py", line 503, in configure
    raise ValueError("dictionary doesn't specify a version")
ValueError: dictionary doesn't specify a version
2013-04-14 17:40:13 [26469] [INFO] Worker exiting (pid: 26469)
2013-04-14 17:40:13 [26464] [INFO] Shutting down: Master
2013-04-14 17:40:13 [26464] [INFO] Reason: Worker failed to boot.
(socialenv)jonathan@li393-189:~/directory$ 
3

3 Answers

20
votes

I had the same error and I fixed it by adding logging configuration to the project's settings file, I used the example from this page

https://docs.djangoproject.com/en/dev/topics/logging/

here is the code from my settings file

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'null': {
            'level': 'DEBUG',
            'class': 'logging.NullHandler',
        },
        'console':{
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
        },
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler',
            'filters': [],
        }
    },
    'loggers': {
        'django': {
            'handlers': ['null'],
            'propagate': True,
            'level': 'INFO',
        },
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': False,
        },
    }
}
13
votes

The easiest way is to add in settings.py:

LOGGING = {
    'version': 1,
}
1
votes

The error message implies that the configuration dictionary passed for logging configuration is missing a schema version. You'll need to show your dictionary to be sure, but that's certainly what the error you're getting is referring to. See the docs for more information.