2

I am trying to fix an issue where an apache log is filling the /var/log/ partition. It is a single log in apache2 that is almost 4GB. I have set logrotate to rotate out at 3G, but it has not rotated the log. Additionally, the logrotate looks like this at the top,

/var/log/apache2/*.log

which seems to imply it will only rotate .log files. The logs in apache2 are sitename.org, with no .log following it. Is this normal behavior/is it why the logs are not rotating properly? There are logs called sitename.org-error.log, and compressed versions of those, but I honestly don't know enough about how apache does logs to know if those are separate logs from the large file taking up the partition.

0

Yes, you are reading that correctly - default logrotate config in your case will only rotate apache2 log files whose name ends in .log.

You could make it rotate all files by using /var/log/apache2/* but that would probably be problematic (as that wildcard would match old rotated log files also)

Your best course of action would be to modify apache config so the logs are called sitename.org.log instead of just sitename.org (of course, you might need to modify the rest of the system if there are script which expect log to be called exactly sitename.org)

Alternatively, you could specify all non-standardly-named logfiles manually, for example:

/var/log/apache2/*.log /var/log/apache2/sitename.org /var/log/apache2/sitename2.org

That would save you the time to fix the hardcoded names in the rest of the system, at the expense of having to manually enter (and later, update!) all the log file names for all domains (not a big deal if there are few of them and you never add new ones).

Also note that logrotate usually runs once a day from cron, so if you set logrotate to rotate at 3GB, it still might grow to more than that (how much more depends on how many lines of log entries are produced in one day)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.