No console output for HTTP request messages from Django 3.1 in Ubuntu 20

I’m new to Ubuntu having come from Mint, but there is a difference when running the default Django development server with the usual:

python manage.py runserver

My local Django server software runs ok with this command, but I don’t see the usual HTTP request messages printed in the console/terminal as pages are accessed via the browser. E.g.

[29/Nov/2019 02:11:35] "GET /foo HTTP/1.1" 200 20

Printing from Django is working fine e.g.

def fooView(request):
    print('here!')
    return render(request, 'foo.html')

How to turn this back on/configure it? (I don’t know if this is due to a change in Django versions, Python, or a difference between Mint and Ubuntu. I can’t seem to find any information on this issue.)

Hi!

This may be related to Django logging.

How do you have configured LOGGING in your settings.py?

1 Like

Hi, thanks for your response.

I have logging configured as so:

    LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'simple': {
            'format': '{levelname} {message}',
            'style': '{'
        },
        'verbose': {
            'format': '{levelname} {asctime} {module} {process:d}'
                '{thread:d} {message}',
            'style': '{'
        }
    },
    'filters': {
        'require_debug_true': {
            '()': 'django.utils.log.RequireDebugTrue',
        }
    },
    'handlers': {
        'file': {
            'class': 'logging.FileHandler',
            'formatter': 'verbose',
            'filename': '/home/daniel/django_bubble.log'
        },
        'console': {
            # 'level': 'INFO',
            'filters': ['require_debug_true'],
            'class': 'logging.StreamHandler',
            'formatter': 'simple'
        }
    },
    'loggers': {
        'django': {
            'handlers': ['file', 'console'],
            'level': 'WARNING',
            'propagate': False
        },
        'django.request': {
            'handlers': ['file', 'console'],
            'level': 'ERROR',
            'propagate': False,
        }
    },
    'root': {
        'handlers': ['file', 'console'],
        'level': 'INFO',
    }
}

“django->level->WARNING” that’s the problem. It should be ‘INFO’. Nice one, thanks marcorichetta.

1 Like