Django logging on Heroku

后端 未结 4 1952
名媛妹妹
名媛妹妹 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:02

    In my case, I did have a valid logging setting

    LOGGING = {...}
    

    Unfortunately it was being ignored because, at the bottom of my setting file, I was calling

    django_heroku.settings(locals())
    

    This was overwriting my logging setting so the solution was

    django_heroku.settings(locals(), logging=False)
    

    This looks as though it might disable logging but it actually just skips heroku's own logging config.


    As a side note, I would use this code when debugging Django logging problems because it should more or less always work with the Django defaults:

    import logging
    logger = logging.getLogger('django.server')
    logger.error('some important infos')
    

    See Django's default logging config

    You can then change the logger, the message level and the logging settings to work out exactly what the problem is.

提交回复
热议问题