Lamp--apache log for the specified file type is not logged

Source: Internet
Author: User
Tags apache log

If a site's traffic is particularly large, then the access log will be many, but there are some access logs we can actually ignore, such as some of the site's pictures, as well as js,css and other static objects. Access to these files is often huge, and logging of these logs is useless, so you can ignore the logs of those visits.

The related configuration is to include the following statement in the virtual host configuration file:

[[email protected] ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf     SetEnvIf Request_URI  ". *\.gif$"  image-request    SetEnvIf  request_uri  ". *\.jpg$"  image-request    SetEnvIf Request_URI  ". *\.png$ " image-request    SetEnvIf Request_URI ". *\.bmp$ " image-request     SetEnvIf Request_URI  ". *\.swf$"  image-request    setenvif  Request_URI  ". *\.js$"  image-request    SetEnvIf Request_URI  ". *\ . css$ " image-request    ErrorLog " |/usr/local/apache2/bin/rotatelogs -l  /usr/local/apache2/logs/123.com-error_%y%m%d_log 86400 "    CustomLog " |/ usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/123.com-access_%y%m%d_log 86400 "  combined env=!image-request 

Note: In the original log configuration, based on the addition of some image-request definition, such as GIF, JPG, BMP, SWF, JS, CSS, such as the end of the full mark as Image-request, and then in the configuration of the log when adding a tag env=! Image-request, there is an exclamation point, which means that the access log is only logged at the end of these characters, with an inverted, non-additive representation.

Restart Apache, browser detection log file, there is no access record of the above file type.

[Email protected] ~]#/usr/local/apache2/bin/apachectl-tsyntax ok[[email protected] ~]#/usr/local/apache2/bin/ Apachectl restart


This article is from the "Learn Notes for students" blog, please make sure to keep this source http://sanyisheng.blog.51cto.com/11154168/1795816

Lamp--apache log for the specified file type is not logged

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.