[Solved]-Manage.py doesn't log to stdout/stderr in Docker on Raspberry Pi

12👍

docker logs shows by default the I/O streams STDOUT and STDERR. Check if
Django logging in your settings.py is properly configured.

For example:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler'
        },
    },
    'loggers': {
        '': {  # 'catch all' loggers by referencing it with the empty string
            'handlers': ['console'],
            'level': 'DEBUG',
        },
    },
}

Source

Also worth to mention:

Changed in Django 1.10:

In older versions, log messages were written
to sys.stderr instead of being handled through Python logging.

https://docs.djangoproject.com/en/1.11/ref/django-admin/#runserver

0👍

I’m not sure if it’s the same problem I was struggling with, but in my situation I couldn’t see any errors informations from Django in my docker console using docker-compose. If for example I had a typo in any of my imports it wouldn’t show me anything, my container just wouldn’t get up.

What helped me was an answer from this thread and after adding ‘tty: true’ in my docker-compose file it got fixed. Now I can see all errors as well as regular prints.

Hope it’s gonna help someone.

Leave a comment