apache日志切割与不记录指定文件类型日志
2015-12-14 16:19
811 查看
1、# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf 修改日志文件为:
ErrorLog "logs/test.com-error_log" 错误日志CustomLog "logs/test.com-access_log" combined 访问日志 相对路径
Apache的common日志格式定义:# 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\"" combinedLogFormat "%h %l %u %t \"%r\" %>s %b" common<IfModule logio_module>%h:客户机的IP地址%l:客户机登陆名称%u:认证用户%t:访问的日期、时间%r:客户访问的方式,访问的什么资源,什么协议%>s 请求对应的状态码 #2开头正常,3开头被重定向,4开头客户端存在错误,5开头服务器端遇到错误%b:传送的字节数%{Referer}: 从哪个页面来的(比如从百度搜索到的QQ空间,那Referer就是百度%{User-Agent}:客户用的什么浏览器# tail -10 test.com-access_log192.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
每天都会有大量的日志,该怎么处理呢?# vim /usr/local/apache2/conf/extra/httpd-vhosts.confErrorLog "logs/test.com-error_log"CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/test.com-access_%Y%m%d_log 86400" combined86400s==一天# ls /usr/local/apache2/logs 此时日志按照天分割test.com-access_20151214_log test.com-error_log
Apache如何做到不记录指定文件类型日志?# !vimvim /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
ErrorLog "logs/test.com-error_log" 错误日志CustomLog "logs/test.com-access_log" combined 访问日志 相对路径
Apache的common日志格式定义:# 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\"" combinedLogFormat "%h %l %u %t \"%r\" %>s %b" common<IfModule logio_module>%h:客户机的IP地址%l:客户机登陆名称%u:认证用户%t:访问的日期、时间%r:客户访问的方式,访问的什么资源,什么协议%>s 请求对应的状态码 #2开头正常,3开头被重定向,4开头客户端存在错误,5开头服务器端遇到错误%b:传送的字节数%{Referer}: 从哪个页面来的(比如从百度搜索到的QQ空间,那Referer就是百度%{User-Agent}:客户用的什么浏览器# tail -10 test.com-access_log192.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
每天都会有大量的日志,该怎么处理呢?# vim /usr/local/apache2/conf/extra/httpd-vhosts.confErrorLog "logs/test.com-error_log"CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/test.com-access_%Y%m%d_log 86400" combined86400s==一天# ls /usr/local/apache2/logs 此时日志按照天分割test.com-access_20151214_log test.com-error_log
Apache如何做到不记录指定文件类型日志?# !vimvim /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
相关文章推荐
- 建立企业信息化-重头开始
- javascript实现的图片切割多块效果实例
- C#实现线程安全的简易日志记录方法
- JS基于cookie实现来宾统计记录访客信息的方法
- 用VBS记录客户机操作的代码
- JS Common 2 之比较常用到的函数第1/3页
- 从数据库中读取记录横向排列
- C++键盘记录程序代码
- PHP判断数据库中的记录是否存在的方法
- android图像绘制(七)ClipRect局部绘图/切割原图绘制总结
- javascript 实现 秒杀,团购 倒计时展示的记录 分享
- MySQL生产库Insert了2次同样的记录但是主键ID是不一样的问题的分析过程
- linux中 shell 历史命令记录功能
- php浏览历史记录的方法
- java实现上传图片进行切割的方法
- Golang记录、计算函数执行耗时、运行时间的一个简单方法
- FileMaker 14学习笔记整理
- 关于awk与其它命令一起使用显示文本信息
- SQL Server 2008安装图解及遇到的问题记录
- Linux/unix 键盘记录 ixkeylog