How do we set the logrotate rule that rotates the logs once they reach 5MB
imlocn123 opened this issue · 4 comments
Is there a way we can set the logrotate rule that rotates the logs once they reach a certain size?
You might want to use the size
or maxsize
config value, depending on your specific use case.
To set the maxsize
attribute, for example:
node.override['logrotate']['global']['maxsize'] = '5M'
If I am understanding the ask correctly, using the resource to accomplish the same thing could be done as follows
logrotate_app 'jboss-app' do
path '/var/log/jboss/jboss.log'
size '100M'
rotate 5
create '664 jboss jboss'
options %w(missingok compress delaycompress)
postrotate 'sudo systemctl restart jboss.service'
end
and it would produce the following logrotate config file:
# This file was generated by Chef for default-ubuntu-1604.vagrantup.com.
# Do not modify this file by hand!
"/var/log/jboss/jboss.log" {
weekly
create 664 jboss jboss
rotate 5
size 100M
missingok
compress
delaycompress
postrotate
sudo systemctl restart jboss.service
endscript
}
I believe it will then rotate at either 100M or weekly, whichever occurs first. May want to test that part out though.
Marking stale due to inactivity. Remove stale label or comment or this will be closed in 7 days. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.
Closing due to inactivity. If this is still an issue please reopen or open another issue. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.