Django logging on Heroku

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

    I had the same problem where my custom logger was not caught by Django and so it would only show my ERROR level messages but without passing through the Django logging system. Formatters and the likes would have no effect on the outputted message and I could not get message of INFO level to show at all.

    I finally found the culprit and it seems to be heroku's django settings tool itself. If you look into the source there, you see it installs a testlogger and does not merge in the custom loggers you may have setup yourself.

    The solution is to do the heroku call like this:

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

    Or better yet, don't use it at all anymore since this package is no longer maintained anyway.

提交回复
热议问题