Best way to rotate Apache log files

I have an Apache server that has one access log file that exceeds 600 MB. This makes it difficult to find a file or analyze it.
What software or modules for Apache are available to make a daily copy of my access file to make it more manageable?

+59
logging apache
Sep 04 '08 at 15:51
source share
7 answers

You looked at logrotate - this is probably the easiest, most widely available and well understood way to achieve this. It is very customizable and will probably do 90% of what you need.

+45
04 Sep '08 at 15:54
source share

I am a big fan of Cronolog . Just install and run your magazines through it. For daily log rotation, something like this would work:

ErrorLog "|/usr/bin/cronolog /path/to/logs/%Y-%m-%d/error.log" CustomLog "|/usr/bin/cronolog /path/to/logs/%Y-%m-%d/access.log" combined 

Quite convenient and easier to install after installation (in my experience) than logrotate.

+26
Sep 04 '08 at 16:12
source share

The actual command for Windows that is hard to find on the Internet is:

 CustomLog '|" "*Apache-Path/bin/rotatelogs.exe" "**Apache-Path*/logs/backup/internet_access_%d-%m-%y.log" 86400' combined 

If the bit "internet_access" is the name you choose for your files, then 86400 is the number of seconds in one day. You need to change Apache-Path to the appropriate directory in which you installed Apache.

+11
Dec 10 '08 at 11:15
source share

logrotate is the best solution. Use the file '/etc/logrotate.conf' to change the settings for all your logs. You change "weekly" to "daily", so magazines change every day. Alternatively, you can add 'compress' so the archives are compressed. If you don't care about old magazines, you can set the turn "turn 4" to something lower.

+6
Sep 04 '08 at 16:00
source share

CustomLog "| bin / rotatelogs / var / logs / logfile 5M" generic

This configuration will rotate the log file whenever it reaches 5 megabytes.

 ErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M" 

This is the best way to redirect Apache logs. There is no need to compile mod with httpd.

+2
Jun 21 '11 at 0:20
source share

rotatelog.exe or cronolog.exe on windows os. They are used in the pipe command in http.conf Mod_log_rotate add-on module for apache ONLY to rotate the Logrotate access log ONLY for unix os.

+1
Aug 04 '10 at 9:22
source share

I have a module that does this for you without the need for external pipes, etc .:

http://www.poptart.org/bin/view/Poptart/ModAutorotate

I tried adding it to the Apache module collection, but it looks like it has now been broken.

0
Nov 27 '10 at 9:22
source share



All Articles