Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I limit the size of Apache's access_log, and limit the number of archived logs it keeps?

Tags:

logging

apache

Apache's access_log file rotates out into an archived copy around 1GB every few days. Where are the settings to control this? I'd like to be able to control both the max size and the number of archived logs it keeps around. Is this part of apache's configuration, or do I need to write cron jobs ( et al ) to deal with this? I'm running pre-forked httpd.

like image 453
T. Brian Jones Avatar asked Jul 11 '12 17:07

T. Brian Jones


People also ask

What is the full absolute path of the log files for Apache?

By default, you can find the Apache access log file at the following path: /var/log/apache/access. log. /var/log/apache2/access.

What is the purpose of access log file in Apache Web server?

What are Apache Access Logs? As mentioned above, the Apache access log is one of several log files produced by an Apache HTTP server. This particular log file is responsible for recording data for all requests processed by the Apache server.


1 Answers

On most Linux distributions, the system is set up to run logrotate on a daily basis. You won't see it in the crontab for root or for any particular user.

It's easy to change how it handles log files. On my Ubuntu server, the /etc/logrotate.conf file has settings like these:

# rotate log files weekly weekly  # keep 4 weeks worth of backlogs rotate 4  # create new (empty) log files after rotating old ones create  # uncomment this if you want your log files compressed #compress 

[etc.]

And, you can look in the directory /etc/logrotate.d/ to see settings for specific directories and apps.

like image 53
Dogweather Avatar answered Sep 28 '22 03:09

Dogweather