This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author LwarX
Recipients LwarX, vinay.sajip
Date 2009-07-14.04:47:58
SpamBayes Score 5.609735e-05
Marked as misclassified No
Message-id <1247546882.95.0.106118390309.issue6444@psf.upfronthosting.co.za>
In-reply-to
Content
> Why can't you either use %r in the format string, or define your own
handler/formatter to do exactly what you want?

I'm describing default behaviour of logger.exception(). Out of the box
(with SyslogHandler and "/dev/log") I'm unable to use it, because of
this problem.

Can you please explain in more details how I can change my code to
correcly log exceptions?  For example:

import logging, logging.handlers

log = logging.getLogger()
h = logging.handlers.SysLogHandler('/dev/log',
logging.handlers.SysLogHandler.LOG_LOCAL0)
h.setFormatter(logging.Formatter('%(name)s: %(levelname)s
%(funcName)s/%(lineno)d %(message)s'))
log.addHandler(h)

try:
        a = 1/0
except:
        log.exception('division by zero')
History
Date User Action Args
2009-07-14 04:48:04LwarXsetrecipients: + LwarX, vinay.sajip
2009-07-14 04:48:02LwarXsetmessageid: <1247546882.95.0.106118390309.issue6444@psf.upfronthosting.co.za>
2009-07-14 04:48:00LwarXlinkissue6444 messages
2009-07-14 04:47:58LwarXcreate