Filtering Apache logs / conditional Logging

Last update on November 14, 2008 08:00 AM by netty5
Published by netty5

Filtering Apache logs / conditional Logging






Log-ins used by Apache Web server is usually very wordy, they contain all type of information (image files, style sheets, javascript, son RSS, etc.)

This can be very troublesome when trying to access certain web pages. The only way to get through is to make use of conditional logging (it is not the only way to control the contents of the logs)
To do this, simply define an environment variable ,according to certain criteria, then request that the server does not write the file type within log when this variable exists:

SetEnvIf Request_URI "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|gz|swf|txt)$" dontlog
SetEnvIf Request_URI "^\/rss\/" dontlog

CustomLog /var/log/apache/access.log combined env=!dontlog


In the example above, requests concerns the following files type .ico, .pdf, .flx, .jpg, .jpeg, .png, .gif, .js, .css, .gz, .swf, ,.txt (they will not be written in the logs), the same goes for for all requests for the /rss/ directory


Note

First of all, the mod_setenvif module must be loaded.
The command apache2-M (or httpd-M, depending on the Apache server installed or distribution used) displays the modules loaded.

Under Debian:

root@debian:~# apache2 -M
Loaded Modules:
 core_module (static)
 log_config_module (static)
 logio_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 alias_module (shared)
 auth_basic_module (shared)
 authn_file_module (shared)
 authz_default_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 dir_module (shared)
 env_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 php5_module (shared)
 setenvif_module (shared)
 status_module (shared)
Syntax OK
Best answers for « Filtering Apache logs / conditional Logging » in :
Web server attacks Show Vulnerability of web services The first network attacks exploited vulnerabilities related to the implementation of TCP/IP protocol suites. With the gradual correction of these vulnerabilities, attacks have shifted to application layers and...
Spreadsheets - Conditional expressions Show What is a Conditional Structure? Conditional structures are instructions that allow to test if a condition is true or not. Conditional structures may be associated together. To successfully execute these tests using logical functions, spreadsheets...
OpenDNS: DNS is quick and useful ShowOpenDNS: DNS is quick and useful DNS Why OpenDNS? How to proceed? Free Disadvantages OpenDNS isn't here Functionality Details of functionality Connecting Adding your IP Changing your IP address See the statistics Filtering adult...
Colouring cells on conditions ShowColouring cells on conditions There are many pratical functions under Excel which is not commonly used. Example: If you wish a cell automatically turns red (or other formatting border, frame etc) under one condition: a result, a...
LAMP(Apache + MySQL + PHP) quick install on Linux ShowLAMP(Apache + MySQL + PHP) quick install on Linux Intro LAMP is the acronym for a free and open source software suite.usually used to define and run dynamic a web server infrastructure ,software development and establish a software...
Download SelectView Filter ShowInternet is certainly an unfailing source of information, but some sites and some Web pages include too many pubs. These pubs block the bandwidth and decelerate considerably your speed of connection. Select View Filter is a program allowing to filter...
Graphic filters ShowFiltering Filtering consists in applying a transformation (called a filtre) to all or to part of a digital image by applying an operator. There are the following types of filters: Low-pass filters, which consist in attenuating image components...
General Terms and Conditions of Use ShowAll Rights Reserved - 2009 - Communitic International Object These General Terms and Conditions are meant to define the ways in which the services of the website en.kioskea.net, hereafter "The Service," are made available, as well as the...
Monitoring event logs ShowAnalysing logs One of the best ways to detect intrusions is to monitor event logs (sometimes called logs for short). In general, servers store logs of their activity, and in particular any errors encountered, in files. Therefore, after a computer...