[Openstack-operators] [Nova][icehouse]Any way to rotating log by size

Zhang, Peng zhang.peng at jp.fujitsu.com
Fri Oct 14 01:53:05 UTC 2016


Dear Kris:

Thank you for quickly reply.

>Add size: 100mb to your logrotate.conf
>It will only logrotate after the size is greater than that size.

Actually my logrotate.conf is just set as you mentioned.
The problems is that the system logrotation works as a cron task
so rotation of log file size will be made only when the task runs.
I have already change the default value of cron interval from daily to hourly
but the frequency is not enough.
The log file size still grows to 160MB or even bigger.
Maybe I should change the cron interval much smaller such as per minute.
Or maybe there is better way?

Best regards

------------------------original reply--------------------------------------
From: Kris G. Lindgren [mailto:klindgren at godaddy.com] 
Sent: Friday, October 14, 2016 10:42 AM
To: Zhang, Peng/張 鵬
Cc: openstack-operators at lists.openstack.org
Subject: Re: [Openstack-operators] [Nova][icehouse]Any way to rotating log by size

Add size: 100mb to your logrotate.conf
It will only logrotate after the size is greater than that size.

Sent from my iPad

On Oct 13, 2016, at 6:03 PM, Zhang, Peng <zhang.peng at jp.fujitsu.com> wrote:
Hi guys,
 
Our disk of Nova controller has been filled with log files several times and it causes the node down.
Although log rotation of Operation system is working fine to make rotation every hour, it is not efficient.
Has anyone got any idea to rotate log files by size (e.g. 100MB) ?
 
It costs time to add a new log achieve server, therefore a temporary solution should be considered.
 
Best regards
From: Peng, Zhang
 
FYI: My own solution(not a good one) is shared here:
Referring to the document : http://docs.openstack.org/developer/oslo.log/configfiles/example_nova.html
I have found a way using python logging modules.
 
I added a configuration file as follows under /etc/nova/ directory:
 
File name: logging.conf
[DEFAULT]
logfile =/var/log/nova/api.log
 
[loggers]
keys = root
 
[handlers]
keys = rotatingfile
 
[formatters]
keys = context
 
[logger_root]
level = DEBUG
handlers = rotatingfile
 
[handler_rotatingfile]
class = handlers.RotatingFileHandler
args = (%(logfile)s, 'a', 5024000, 5)
formatter = context
 
[formatter_context]
class = nova.openstack.common.log.ContextFormatter
 
And I also changed this parameter in nova.conf to make nova use the above configuration:
log_config_append=/etc/nova/logging.conf
 
Everything seems going well except that all nova services such as api, scheduler, etc. begin
to put their log messages into the same file(api,log)!
 
So I have to put a script to replace the file name defined in DEFAULT session:
logfile = '%s.log' % (os.path.join('/var/log', *os.path.basename(__import__('inspect').stack()[-1][1]).split('-')))
 
It works but it’s also weird.
_______________________________________________
OpenStack-operators mailing list
OpenStack-operators at lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-operators


More information about the OpenStack-operators mailing list