Apache log cutting with no logging of specified file types

Source: Internet
Author: User
Tags format definition apache log

1. # vim/usr/local/apache2/conf/extra/httpd-vhosts.conf

Modify the log file to:

Errorlog "Logs/test.com-error_log" error log

Customlog "Logs/test.com-access_log" combined access log relative path


Apache's Common log format definition:

# vim/usr/local/apache2/conf/httpd.conf

<ifmodule log_config_module>

# The following directives define some format nicknames for use with

# a Customlog directive (see below).

Logformat "%h%l%u%t \"%r\ "%>s%b \"%{referer}i\ "\"%{user-agent}i\ "" combined

Logformat "%h%l%u%t \"%r\ "%>s%b" common

<ifmodule logio_module>

%H: IP address of the client

%l: Client Login Name

%u: Authenticated Users

%t: Date and time of the visit

%r: How customers access, what resources to access, what agreements

%>s request corresponding status code #2开头正常, 3 start is redirected, 4 start client present error, 5 Start server side encounters error

%b: Number of bytes transferred

%{referer}: from which page (such as Baidu Search to the QQ space, that Referer is Baidu

%{user-agent}: What browser does the customer use

# tail-10 Test.com-access_log

192.168.101.175--[01/dec/2015:14:36:52 +0800] "get/misc.php?mod=patch&action =pluginnotice&inajax=1&ajaxtarget=plugin_notice http/1.1 "200 63


There will be a lot of logs every day, how to deal with it?

# vim/usr/local/apache2/conf/extra/httpd-vhosts.conf

Errorlog "Logs/test.com-error_log"

Customlog "|/usr/local/apache2/bin/rotatelogs-l/usr/local/apache2/logs/test.com-access_%y%m%d_log 86400" combined

86400s== Day

# Ls/usr/local/apache2/logs This time the log is divided by day

Test.com-access_20151214_log Test.com-error_log


How does Apache do not log the specified file type?

#!vim

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 "Logs/test.com-error_log"

Customlog "|/usr/local/apache2/bin/rotatelogs-l/usr/local/apache2/logs/test.com-access_%y%m%d_log 86400" combined env=!image-reqest




Apache log cutting with no logging of specified file types

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.