Reducing logging in Apache

Kurt Wall kwall
Mon Dec 6 14:44:37 PST 2004


On Mon, Dec 06, 2004 at 04:10:17PM -0700, Brian Simper took 21 lines to write:
> I have a small Apache web server on Red Hat Enterprise Linux 3.0.  I
> am still rather new to Apache but it does function quite well. 
> However, the logs are filling up quickly and I would like to slow this
> down.  Is there a simple way to *not* log graphics?  This is a simple
> department web server within a corporate firewall and we don't need to
> track access to pictures.  Also are there any general guidelines for
> reduce overall log chattiness?  I would be happy with reducing the log
> to show a simple tally of pages accessed.

You have a couple of options. First of all, Apache regards a "page"
as any request. If you are only interested in logging HTML pages loaded,
something like the following untested configuration might do:

SetEnvIf Request_URI \.html$ html-pages
CustomLog html-pages.log common env=html-pages
CustomLog "|>/dev/null" env=!html-pages

This logs all files retrieved whose names end with ".html" to
$LOGDIR/html-pages.log. Everything else goes to /dev/null. Works over here,
but YMMV and if it breaks you get to keep both pieces.

Personally, I think you're going about this the wrong way. Log everything,
just rotate the logs each day/week/month or whatever the corporate policy
dictates. I hate to lose data.

Kurt
-- 
No man is an island, but some of us are long peninsulas.


More information about the Linux-users mailing list