Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
317 views
in Technique[技术] by (71.8m points)

Django application Logs not showing in Heroku

I have a Django application deployed on Heroku.
I am using the default logging module, and my logs show normally in development, both when DEBUG is True and False.

Though, I am unable to see the logs when deployed to heroku with the command heroku logs --tail.

Here is the content of my settings.py file:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'simple': {
            'format': '{levelname} [{asctime}] module:{module} - {message}',
            'style': '{',
        },
    },
    'handlers': {
        'console': {
            'class': 'logging.StreamHandler',
            'formatter': 'simple',
            'stream': sys.stdout,
        },
    },
    'loggers': {  # I tried replacing this with 'root'
        '': {
            'handlers': ['console'],
            'level': 'DEBUG',
        },
    }
}

In my files such as views.py:

import logging

logger = logging.getLogger(__name__)
logging.debug('something...')

And finally, in my Procfile:

release: python manage.py migrate --settings=myapp.deploy_settings
web: gunicorn myapp.wsgi --log-file -

I also tried with web: gunicorn myapp.wsgi --log-file=- as mentioned in a StackOverflow post, without success.

What is causing this?

question from:https://stackoverflow.com/questions/65851349/django-application-logs-not-showing-in-heroku

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Adding logging=False to django_heroku.settings(locals(), logging=False) solved the issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...