Fixes #4622: Change logrotate logic to be more clean (use of templates)