[openstack-dev] Logging and traceback at same time.

joehuang joehuang at huawei.com
Sun Feb 14 02:46:39 UTC 2016

Hi, Doug,

Partly agree with you that " Tracebacks should be logged for errors the application can't recover from." From maintenance perspective, if some exception happened, the engineer needs to find out what causes the exception and decide to do some work to prevent more sever issue occurred. There are many different ways lead to the same exception, only know exception is not enough, even how the route leads to the exception is also very important information for cloud maintenance. That's the importance to record the trace-back and context information.

Best Regards
Chaoyi Huang ( Joe Huang )

-----Original Message-----
From: Doug Hellmann [mailto:doug at doughellmann.com] 
Sent: Wednesday, February 03, 2016 11:47 PM
To: openstack-dev
Subject: Re: [openstack-dev] Logging and traceback at same time.

Excerpts from Khayam Gondal's message of 2016-02-03 11:28:52 +0500:
> Is there a way to do logging the information and traceback at the same time. Currently I am doing it like this.
> LOG.error(_LE('Record already exists: %(exception)s '
>                      '\n %(traceback)'),
>                        {'exception': e1},
>                        {'traceback': traceback.print_stack()}).
> Let me know if this is correct way?
> Regards

You've had a couple of responses with tips for how to log the traceback.
Before you adopt those approaches, please consider whether you actually need it or not, though.

Tracebacks should be logged for errors the application can't recover from. They shouldn't be logged for user errors, warnings, or errors that an operator can fix without changing source code. Errors the operator can handle should be logged with details about what happened, but not the traceback.

Our logging guidelines are available at


OpenStack Development Mailing List (not for usage questions)
Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe

More information about the OpenStack-dev mailing list