为opentack 日志添加行号

查看openstack的nova-api模块的日志:

tail -f /var/log/nova/nova-api.log

2016-12-13 17:50:46.683 20713 INFO nova.openstack.common.service [-] Started child 20742
2016-12-13 17:50:46.689 20713 INFO nova.openstack.common.service [-] Started child 20743
2016-12-13 17:50:46.690 20742 INFO nova.metadata.wsgi.server [-] (20742) wsgi starting up on http://0.0.0.0:8775/
2016-12-13 17:50:46.694 20713 INFO nova.openstack.common.service [-] Started child 20744

有模块信息,但是没有行号,不知道打日志的具体位置,修改文件[这里前缀替换为你nova放的位置]nova\openstack\common\log.py中的logging_default_format_string,添加[%(lineno)d]

log_opts = [
cfg.StrOpt(‘logging_context_format_string’,
default=’%(asctime)s.%(msecs)03d %(process)d %(levelname)s ’
‘%(name)s [%(lineno)d] [%(request_id)s %(user_identity)s] ’
‘%(instance)s%(message)s’,
help=’Format string to use for log messages with context.’),
cfg.StrOpt(‘logging_default_format_string’,
default=’%(asctime)s.%(msecs)03d %(process)d %(levelname)s ’
‘%(name)s [%(lineno)d] %(instance)s%(message)s’,
help=’Format string to use for log messages without context.’),
cfg.StrOpt(‘logging_debug_format_suffix’,
default=’%(funcName)s %(pathname)s:%(lineno)d’,
help=’Data to append to log format when level is DEBUG.’),
cfg.StrOpt(‘logging_exception_prefix’,
default=’%(asctime)s.%(msecs)03d %(process)d TRACE %(name)s ’
‘%(instance)s’,
help=’Prefix each line of exception output with this format.’),
cfg.ListOpt(‘default_log_levels’,
default=DEFAULT_LOG_LEVELS,
help=’List of logger=LEVEL pairs.’),
cfg.BoolOpt(‘publish_errors’,
default=False,
help=’Enables or disables publication of error events.’),
cfg.BoolOpt(‘fatal_deprecations’,
default=False,
help=’Enables or disables fatal status of deprecations.’),

日志多了行号:

2016-12-13 19:14:32.236 21934 INFO nova.metadata.wsgi.server [620] (21934) wsgi starting up on http://0.0.0.0:8775/
2016-12-13 19:14:32.236 21900 INFO nova.openstack.common.service [329]Started child 21935
2016-12-13 19:14:32.240 21935 INFO nova.metadata.wsgi.server [620](21935) wsgi starting up on http://0.0.0.0:8775/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值