In the Apache access log, all actions are logged by default. Includes some local static small pictures, so the log becomes bloated.
At this point we can specify that the log of the specified file type is not logged, so that only the log we want is logged.
Configuration steps:
1: Mark specified file type
<virtualhost *:80>
ServerAdmin [email protected]
DocumentRoot "/usr/local/src/discuz"
ServerName www.llzdwyp.com
Serveralias www.wyp.com
Serveralias www.hdnet.com
<ifmodule mod_rewrite.c>
Rewriteengine on
Rewritecond%{http_host} ^www.wyp.com$ [OR]
Rewritecond%{http_host} ^www.hdnet.com$
Rewriterule ^/(. *) $ http://www.llzdwyp.com/$1 [r=301,l]
</IfModule>
setenvif Request_uri ". *\.gif$" Image-request
Setenvif Request_uri ". *\.jpg$" Image-request
Setenvif Request_uri ". *\.bmp$" Image-request
Setenvif Request_uri ". *\.swf$" Image-request
Setenvif Request_uri ". *\.css$" Image-request
Setenvif Request_uri ". *\.js$" Image-request
Setenvif Request_uri ". *\.png$" Image-request
errorlog "Logs/dummy-host.example.com-error_log"
Customlog "|/usr/local/apache2/bin/rotatelogs-l/usr/local/apache2/logs/%y%m%d-access_log 86400" combined
Where Requiest_uri represents 192.168.11.201 in the log record--[22/aug/2015:00:28:38 +0800] "get/static/image/common/pt_item.png http/1.1 "301 262" http://www.llzdwyp.com/forum.php "" mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; trident/6.0; SLCC2;. NET CLR 2.0.50727;. NET CLR 3.5.30729;. NET CLR 3.0.30729;. net4.0c;. NET4.0E) "
get this action after the domain name sub-address
". *\.gif$" represents the end of a. gif
Image-request Representative Mark
2: Tag Processing
Customlog "|/usr/local/apache2/bin/rotatelogs-l/usr/local/apache2/logs/%y%m%d-access_log 86400" combined env=! Image-request
That is, env is not equal to the tag image-request the log that does not record the tag
2.1-apache log of specified file types is not logged