<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p> <strong>Preamble</strong><br>
Hi stackers, I was trying to implement correct APP-NAME tags for
remote logging in Fuel for Openstack, and faced the <a
href="https://bugs.launchpad.net/nova/+bug/904307"
title="https://bugs.launchpad.net/nova/+bug/904307">https://bugs.launchpad.net/nova/+bug/904307</a>
issue. 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)).<br>
</p>
<p> Just look at the log file names, and you will understand me:<br>
<font face="Courier New">cinder-cinder.api.extensions.log<br>
cinder-cinder.db.sqlalchemy.session.log<br>
cinder-cinder.log<br>
cinder-cinder.openstack.common.rpc.common.log<br>
cinder-eventlet.wsgi.server.log<br>
cinder-keystoneclient.middleware.auth_token.log<br>
glance-eventlet.wsgi.server.log<br>
glance-glance.api.middleware.cache.log<br>
glance-glance.api.middleware.cache_manage.log<br>
glance-glance.image_cache.log<br>
glance-keystoneclient.middleware.auth_token.log<br>
keystone-root.log<br>
nova-keystoneclient.middleware.auth_token.log<br>
nova-nova.api.openstack.compute.extensions.log<br>
nova-nova.api.openstack.extensions.log<br>
nova-nova.ec2.wsgi.server.log<br>
nova-nova.log<br>
nova-nova.metadata.wsgi.server.log<br>
nova-nova.network.driver.log<br>
nova-nova.osapi_compute.wsgi.server.log<br>
nova-nova.S3.log<br>
quantum-eventlet.wsgi.server.log<br>
quantum-keystoneclient.middleware.auth_token.log<br>
quantum-quantum.api.extensions.log<br>
quantum-quantum.manager.log<br>
quantum-quantum.openstack.common.rpc.amqp.log<br>
quantum-quantum.plugins.openvswitch.ovs_quantum_plugin.log</font><br>
</p>
<p> But I actually want to see something like this:<br>
<font face="Courier New">cinder-api.log<br>
cinder-volume.log<br>
glance-api.log<br>
glance-manage.log<br>
glance-registry.log<br>
keystone-all.log<br>
nova-api.log<br>
nova-conductor.log<br>
nova-consoleauth.log<br>
nova-objectstore.log<br>
nova-scheduler.log</font><br>
...and so on.<br>
</p>
<p> Another words, logging should honor RFC3164 & RFC5424, here
are some quotes:<br>
"The MSG part has two fields known as the TAG field and the
CONTENT<br>
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..."<br>
"The APP-NAME field SHOULD identify the device or application that<br>
originated the message..."<br>
</p>
<p> I see two solutions for this issue.<br>
</p>
<p> <strong>Solution 1</strong><br>
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.<br>
The implementation could be like patch #4: <a
href="https://review.openstack.org/#/c/63094/4"
title="https://review.openstack.org/#/c/63094/4">https://review.openstack.org/#/c/63094/4</a><br>
And the log_format could be like this:<br>
<font face="Courier New">log_format=%(asctime)s %(binary_name)s
%(levelname)s: %(name)s: %(message)s</font><br>
</p>
<p> The patch is applicable to other Openstack services, which did
not moved to Oslo yet.<br>
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 <a
href="http://paste.openstack.org/show/55519/"
title="http://paste.openstack.org/show/55519/">http://paste.openstack.org/show/55519/</a><br>
</p>
<p> <strong>Solution 2</strong><br>
The other and only option I can suggest, is to backport ‘ident’
from python 3.3, see <a
href="http://hg.python.org/cpython/rev/6baa90fa2b6d"
title="http://hg.python.org/cpython/rev/6baa90fa2b6d">http://hg.python.org/cpython/rev/6baa90fa2b6d</a><br>
The implementation could be like this: <a
href="https://review.openstack.org/#/c/63094"
title="https://review.openstack.org/#/c/63094">https://review.openstack.org/#/c/63094</a><br>
To ensure we will have APP-NAME in message we can set use_syslog =
true and check the results. <br>
If we’re using log_config_append, the formatters and handlers
could be like this:<br>
<font face="Courier New">[formatter_normal]<br>
format = %(levelname)s: %(message)s<br>
[handler_production]<br>
class = openstack.common.log.RFCSysLogHandler<br>
level = INFO<br>
formatter = normal<br>
args = ('/dev/log', handlers.SysLogHandler.LOG_LOCAL6)</font><br>
</p>
<p> The patch is also applicable to other Openstack services, which
did not moved to Oslo yet.<br>
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.<br>
</p>
<p> <strong>Conclusion</strong><br>
I vote for 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?</p>
<pre class="moz-signature" cols="72">
P.S. Sorry for spamming, fuel-dev, have a nice weekend :-)
--
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
<a class="moz-txt-link-abbreviated" href="http://www.mirantis.com">www.mirantis.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.mirantis.ru">www.mirantis.ru</a>
<a class="moz-txt-link-abbreviated" href="mailto:bdobrelia@mirantis.com">bdobrelia@mirantis.com</a></pre>
</body>
</html>