Django+heroku: django logs appear, app logs don't
<p>I read all the StackOverflow answers, all the blog posts on the subject, and tried everything twice, but I still can't get my Django app's log messsages to appear in the heroku log (Django's own messages do appear).</p>

<p>Can anyone please paste a full LOGGING config that works in heroku?</p>

<pre><code># views.py
import logging
logger = logging.getLogger(__name__)

def a_view(request):
    # ...
    logger.exception('error finding file')
    # ...
</code></pre>

<p>with:</p>

<pre><code># settings.py
LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    'formatters': {
        'simple': {
            'format': '%(levelname)s [%(name)s:%(lineno)s] %(message)s'
        },
    },
    'handlers': {
        'console': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'formatter': 'simple',
            "stream": sys.stdout
        },
    },
    "loggers": {
        "root": {
            "handlers": ["console"],
        },
        # last try :(
        "myapp": {
            "handlers": ["console"],
        },
        "django": {
            "handlers": ["console"],
        }
    }
}
</code></pre>

<p>Here is a configuration that worked for me (OP):</p>

<pre><code>LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    'formatters': {
        'simple': {
            'format': '%(levelname)s [%(name)s:%(lineno)s] %(message)s'
        },
    },
    'handlers': {
        'console': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'formatter': 'simple',
            "stream": sys.stdout
        },
    },
    "loggers": {
        "": {
            "handlers": ["console"],
            'level': 'INFO',
        },
        "django": {
            "handlers": ["console"],
            'level': 'INFO',
        }
    }
}
</code></pre>

<p>The modification that made the difference is changing the level of all loggers, but before that I changed <code>"root"</code> to <code>""</code>, so that might have been needed too.</p>

<p>edit: removed "myapp" logger as it is captured by "" logger, resolved my double logging issue.</p>

python django logging heroku