Apache Log Management

What's the simplest way (other than not logging in the first place) to keep apache access log files from growing to huge sizes?

Ideally I'd like to keep some sort of log history – at least 24 hours. But I don't want to install anything complicated. Using a basic LAMP setup. Probably should do something similar for php logs also…

??

8 Replies

Install log rotate it'll rotate your logs automatically.

@obs:

Install log rotate it'll rotate your logs automatically.

Do you mean this: http://httpd.apache.org/docs/2.2/progra … elogs.html">http://httpd.apache.org/docs/2.2/programs/rotatelogs.html

Nope this http://linuxcommand.org/man_pages/logrotate8.html, your distro will have it as a package try apt-get install logrotate for debian/ubuntu

Odd, normally most distributions will automatically install/configure logrotate when you install any package that produces logs (like apache).

On the subject…if I just do nothing and let the log file grow and grow, is there a limit (ie file size) beyond which there would be some kind of performance issue?

Well, if you're using an ext3 or ext4 filesystem, I think there's a file size limit of 2^24 blocks (16GB-2TB depending on block size). Other than this, writing the log shouldn't be much of a problem, but moving/searching/analyzing a huge file can take a long time. Another benefit of logrotate is that it can automatically compress older log files for you.

A bigger problem is that you'll eventually run out of disk space. (Keep in mind that there are many other log files on your system as well, which logrotate also rotates.)

Thanks for the info – I'll look into configuring that solution.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct