Re: [openstack-dev] [log] LOG.exception should contain an exception message or not?
On Tue, Jan 05, 2016 at 10:08:42PM +0900, Akihiro Motoki wrote: > Hi, > > # cross-posting to -dev and -operators ML > > In the current most OpenStack implementation, > when we use LOG.exception, we don't pass an exception message to > LOG.exception: > > LOG.exception(_LE("Error while processing VIF ports")) > > IIUC it is because the exception message will be logged at the end of > a corresponding stacktrace. > > We will get a line like (Full log: http://paste.openstack.org/show/483018/): > > ERROR ... Error while processing VIF ports > > [Problem] > > Many logging tools are still line-oriented (though logstash or fluentd > can handle multiple lines). > An ERROR line only contains a summary message without the actual failure > reason. > This makes difficult for line-oriented logging tools to classify error logs. > > [Proposal] > > My proposal is to pass an exception message to LOG.exception like: > > except as exc: > LOG.exception(_LE("Error while processing VIF ports: %s"), exc) Why use LOG.exception then? It sounds like for what you are looking for you would be better off using LOG.error and passing in your exception details. The only benefit that LOG.exception gives you over LOG.error is that it will automatically log out whatever exception is in scope. It is still at the ERROR level of logging. So if the results from LOG.exception don't give you what you want, the exact same resulting behavior can be accomplished by LOG.error with a message string formatted however you desire. That would be my recommendation at least. :) Sean (smcginnis) > > This alllows line-oriented logging tools to classify error logs more easily. > > > Thought? > > Thanks, > Akihiro > > __ > OpenStack Development Mailing List (not for usage questions) > Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev __ OpenStack Development Mailing List (not for usage questions) Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Re: [openstack-dev] [log] LOG.exception should contain an exception message or not?
Excerpts from Sean Dague's message of 2016-01-05 08:31:34 -0500: > On 01/05/2016 08:08 AM, Akihiro Motoki wrote: > > Hi, > > > > # cross-posting to -dev and -operators ML > > > > In the current most OpenStack implementation, > > when we use LOG.exception, we don't pass an exception message to > > LOG.exception: > > > > LOG.exception(_LE("Error while processing VIF ports")) > > > > IIUC it is because the exception message will be logged at the end of > > a corresponding stacktrace. > > > > We will get a line like (Full log: http://paste.openstack.org/show/483018/): > > > > ERROR ... Error while processing VIF ports > > > > [Problem] > > > > Many logging tools are still line-oriented (though logstash or fluentd > > can handle multiple lines). > > An ERROR line only contains a summary message without the actual failure > > reason. > > This makes difficult for line-oriented logging tools to classify error logs. > > > > [Proposal] > > > > My proposal is to pass an exception message to LOG.exception like: > > > > except as exc: > > LOG.exception(_LE("Error while processing VIF ports: %s"), exc) > > > > This alllows line-oriented logging tools to classify error logs more easily. > > What tools are you talking about here? > > Realistically this is a trade off. Stack traces should only be happening > under exceptional circumstances, which means a user is going to be > engaged. The user is going to have a much easier time reading an > exception in a log if it's not got all the whitespace compressed out of it. > > If it's possible to recover, the code that is generating the exception > shouldn't be logging it, but instead should do some kind of structured > recovery. > > -Sean > Right, LOG.error() with a summary of an error is better. Stack traces should really only be logged as a last resort. Doug __ OpenStack Development Mailing List (not for usage questions) Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Re: [openstack-dev] [log] LOG.exception should contain an exception message or not?
On 01/05/2016 08:08 AM, Akihiro Motoki wrote: > Hi, > > # cross-posting to -dev and -operators ML > > In the current most OpenStack implementation, > when we use LOG.exception, we don't pass an exception message to > LOG.exception: > > LOG.exception(_LE("Error while processing VIF ports")) > > IIUC it is because the exception message will be logged at the end of > a corresponding stacktrace. > > We will get a line like (Full log: http://paste.openstack.org/show/483018/): > > ERROR ... Error while processing VIF ports > > [Problem] > > Many logging tools are still line-oriented (though logstash or fluentd > can handle multiple lines). > An ERROR line only contains a summary message without the actual failure > reason. > This makes difficult for line-oriented logging tools to classify error logs. > > [Proposal] > > My proposal is to pass an exception message to LOG.exception like: > > except as exc: > LOG.exception(_LE("Error while processing VIF ports: %s"), exc) > > This alllows line-oriented logging tools to classify error logs more easily. What tools are you talking about here? Realistically this is a trade off. Stack traces should only be happening under exceptional circumstances, which means a user is going to be engaged. The user is going to have a much easier time reading an exception in a log if it's not got all the whitespace compressed out of it. If it's possible to recover, the code that is generating the exception shouldn't be logging it, but instead should do some kind of structured recovery. -Sean -- Sean Dague http://dague.net __ OpenStack Development Mailing List (not for usage questions) Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
[openstack-dev] [log] LOG.exception should contain an exception message or not?
Hi, # cross-posting to -dev and -operators ML In the current most OpenStack implementation, when we use LOG.exception, we don't pass an exception message to LOG.exception: LOG.exception(_LE("Error while processing VIF ports")) IIUC it is because the exception message will be logged at the end of a corresponding stacktrace. We will get a line like (Full log: http://paste.openstack.org/show/483018/): ERROR ... Error while processing VIF ports [Problem] Many logging tools are still line-oriented (though logstash or fluentd can handle multiple lines). An ERROR line only contains a summary message without the actual failure reason. This makes difficult for line-oriented logging tools to classify error logs. [Proposal] My proposal is to pass an exception message to LOG.exception like: except as exc: LOG.exception(_LE("Error while processing VIF ports: %s"), exc) This alllows line-oriented logging tools to classify error logs more easily. Thought? Thanks, Akihiro __ OpenStack Development Mailing List (not for usage questions) Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev