Forums

root logger

Hi, in my Sentry logs I am seeing that a single Python exception creates multiple Sentry events, one for each line of the traceback:

enter image description here

This is not supposed to happen. I guess that logger.error is being called somewhere for each line of a stringified traceback. The screenshot shows that it comes from a logger called "root", but I don't have any "root" logger defined in my project, as I am using the default Django logging config (with the minor addition of 'myproject' logger):

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'filters': {
        'require_debug_false': {'()': 'django.utils.log.RequireDebugFalse'},
        'require_debug_true': {'()': 'django.utils.log.RequireDebugTrue'},
    },
    'formatters': {
        'django.server': {
            '()': 'django.utils.log.ServerFormatter',
            'format': '[%(server_time)s] %(message)s',
        }
    },
    'handlers': {
        'console': {
            'level': 'INFO',
            'filters': ['require_debug_true'],
            'class': 'logging.StreamHandler',
        },
        'django.server': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'formatter': 'django.server',
        },
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler',
        },
    },
    'loggers': {
        'django': {'handlers': ['console', 'mail_admins'], 'level': 'INFO'},
        'myproject': {'handlers': ['console'], 'level': 'INFO'},
        'django.server': {
            'handlers': ['django.server'],
            'level': 'INFO',
            'propagate': False,
        },
    },
}

I am wondering if PythonAnywhere adds a logger called "root"? By the way, what server does PythonAnywhere use? Is it gunicorn?

Thanks!

Yes, we have a logger that takes the logs generated by the web app and sends them to be stored in the log files that you eventually see. We break the logs on lines in order to make them legible in your log files.

We use uWSGI as the server.