Django logging on Heroku

后端 未结 4 1981
名媛妹妹
名媛妹妹 2020-12-29 21:32

I know this question was already asked several times, but I just can\'t get it to work. I already spent half a day trying dozens of combinations, and again now and it is sti

4条回答
  •  太阳男子
    2020-12-29 22:04

    You need to 'activate' your loggers manually. You can do this per module, like 'blog.views'. It will pick up submodules, so to log the whole blog app, just put in 'blog'.

    If you leave it empty, it will log everything not handled before and with propagate=True (not the default). This will also log all of Django, which means on debug level you will get SQL queries in your logs.

    'loggers': {
            'django.request': {
                'handlers': ['mail_admins'],
                'level': 'ERROR',
                'propagate': False,
            },
            'blog.views': {
                'handlers': ['console'],
            },
            'blog': {
                'handlers': ['console'],
            },
            '': {
                'handlers': ['console'],
                'level': 'DEBUG',  # Not recommended.
            }
        }
    

提交回复
热议问题