How do I use Django’s logger to log a traceback when I tell it to?

You can use python’s logging mechanism:

import logging
...

logger = logging.getLogger("blabla")
...

try:
    print blah # You can use logger.debug("blah") instead of print
except KeyError:
    logger.exception("An error occurred")

This will print the stack trace and will work with apache.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)