← Back to team overview

fuel-dev team mailing list archive

[Fuel] Add APP-NAME (RFC5424) for Oslo syslog logging (#904307 related)

 

*


   Preamble

Hello, all.
I was trying to implement correct APP-NAME tags for remote logging in Fuel for Openstack, and faced the https://bugs.launchpad.net/nova/+bug/904307issue. There are no logging options in Python 2.6/2.7 to address this APP-NAME in logging formats or configs (log_format, log_config(_append)).

Another words, logging should honour RFC3164 & RFC5424, here are some quotes:

"The MSG part has two fields known as the TAG field and the CONTENT

field. The value in the TAG field will be the name of the program or process that generated the message. The CONTENT contains the details of the message..."

"The APP-NAME field SHOULD identify the device or application that

originated the message..."


   Solution 1

The one of possible solutions is to use new key for log_format ( i.e. %(binary_name)s ) to extract application/service name for log records.

The implementation could be like patch #4: https://review.openstack.org/#/c/63094/4

And the log_format could be like this:

log_format=%(asctime)s.%(msecs)06d+00:00 %(binary_name)s%(levelname)s: %(name)s: %(message)s


The patch is applicable to other Openstack services, which did not moved to Oslo yet.

I tested it with nova services, and all services can start with log_format using %(binary_name)s, but nova-api. Looks like /keystoneclient/middleware/auth_token.py is unhappy with this patch, see the trace http://paste.openstack.org/show/55519/


   Solution 2

The other and only option I can suggest, is to backport 'ident' from python 3.3, see http://hg.python.org/cpython/rev/6baa90fa2b6d

The implementation could be like this: https://review.openstack.org/#/c/63094

To ensure we will have APP-NAME in message we can set use_syslog = true and check the results.

If we're using log_config_append, the formatters and handlers could be like this:

[formatter_normal]

format = %(levelname)s: %(message)s

[handler_production]

class = openstack.common.log.RFCSysLogHandler

level = INFO

formatter = normal

args = ('/dev/log', handlers.SysLogHandler.LOG_LOCAL6)


The patch is also applicable to other Openstack services, which did not moved to Oslo yet.

For syslog logging, the application/service/process name (aka APP-NAME, see RFC5424) would be added before the MSG part, right after it has been formatted, and there is no need to use any special log_format settings as well.


   Conclusion

I believe we should implement solution 2 for Oslo logging, and for those Openstack services, which don't use Oslo for logging yet. That would not require any changes outside of the Openstack modules, thus looks like a good compromise for backporting 'ident' feature for APP-NAME tags from Python 3.3. What do you think?**

*

--
Best regards,
Bogdan Dobrelya,
Researcher TechLead, Mirantis, Inc.
+38 (066) 051 07 53
Skype bogdando_at_yahoo.com
Irc #bogdando
38, Lenina ave.
Kharkov, Ukraine
www.mirantis.com
www.mirantis.ru
bdobrelia@xxxxxxxxxxxx