日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Apache访问日志切割

發(fā)布時間:2025/5/22 编程问答 15 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Apache访问日志切割 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

[root@daixuan ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf?

修改日志文件為:

ErrorLog "logs/test.com-error_log" ? ? ??logs目錄位置是相對于/usr/local/apache2

CustomLog "logs/test.com-access_log" combined


Apache的common日志格式定義:

[root@daixuan ~]# 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 192.168.101.175

%u ? ? ? ? ? 用戶 ?user1

%t ? ? ? ? ? 時間 ?

\"%r\" ? ? ? ?動作,get

"%{Referer}i\" ? 鏈接地址

"%{User-Agent}i ?瀏覽器的Agent

[root@daixuan logs]# 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


每天都會有大量的日志,該怎么處理呢?

[root@daixuan logs]# 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==一天

[root@daixuan logs]# ls /usr/local/apache2/logs ? ? ? 此時日志按照天分割

test.com-access_20151201_log ?test.com-error_log


Apache如何做到不記錄指定文件類型日志?

[root@daixuan logs]# !vim

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

? ? SetEnvIf Request_URI ".*\.gif$" p_w_picpath-request

? ? SetEnvIf Request_URI ".*\.jpg$" p_w_picpath-request

? ? SetEnvIf Request_URI ".*\.png$" p_w_picpath-request

? ? SetEnvIf Request_URI ".*\.bmp$" p_w_picpath-request

? ? SetEnvIf Request_URI ".*\.swf$" p_w_picpath-request

? ? SetEnvIf Request_URI ".*\.js$" p_w_picpath-request

? ? SetEnvIf Request_URI ".*\.css$" p_w_picpath-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=!p_w_picpath-reqest

文件結(jié)尾不是:gif,jpg,png......才會記錄到日志中。

[root@daixuan logs]# apachectl -t

Syntax OK

[root@daixuan logs]# apachectl restart

重新訪問瀏覽器,打開幾個測試頁面,查看日志,發(fā)現(xiàn)gif,jpg,png....結(jié)尾的文件都沒有記錄到日志

轉(zhuǎn)載于:https://blog.51cto.com/daixuan/1718457

總結(jié)

以上是生活随笔為你收集整理的Apache访问日志切割的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。