Logging in Django on Heroku not appearing

后端 未结 4 2344
借酒劲吻你
借酒劲吻你 2021-02-19 05:22

I have created an app on Heroku and I push my Django app to it.

I monitor the logs using heroku logs --tail to see them in real time.

Then, in my

4条回答
  •  不要未来只要你来
    2021-02-19 05:51

    As stated in previous replies, the logger should be set up in the entry point to your app. In the case of a django based web server using gunicorn, that entry point is most likely the wsgi.py file. Try adding the required configuration to that file, e.g. setting the global basic logger:

    import logging
    import os
    
    from dj_static import Cling
    
    from django.core.wsgi import get_wsgi_application
    
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "path.to.settings.py")
    
    logging.basicConfig(
        level=logging.INFO,
        format="%(asctime)s %(name)s %(levelname)-8s %(message)s",
    )
    

提交回复
热议问题