s %b \"%{Re_apache日志配置">
赞
踩
Apache日志位置 /usr/local/apache2/logs/
vi /usr/local/apache2/conf/httpd.conf
1)搜索:/log_config
检查该模块是否开启(默认开启)
2)查看日志相关格式规定
搜索:/LogFormat
#就可以看到以下内容(%h 是来源ip;%u是访问user;%t是时间;%r是动作)
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
# Web服务器会出现大量的访问日志和错误日志,所以我们要对日志进行切割,方便管理查询。
# 在<VirtualHost>标签内添加如下内容
CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/007.com-access_%Y%m%d_log 86400" combined
# 1-1.重启httpd服务
/usr/local/apache2/bin/apachectl restart
# 1-2.修改时间进行测试
date 04040000 #4月4日
curl ip
data 04050000 #4月5日
curl ip
# 1-3.查看日志是否产生
ls /usr/local/apache2/logs/
# 网站上的图片,还有 js,css 等静态对象。用户对它们的访问往往是巨大的,记录这些日志也没什么用,那就可以不记录这些。 # 在<VirtualHost>标签内添加如下内容 ErrorLog "logs/007.com-error_log" 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 CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/007.com-access_%Y%m%d_log 86400" combined env=!image-request # 不记录做过标记的文件 # 2-1.检查配置文件是否有语法错误 /usr/local/apache2/bin/apachectl -t # 2-2.如果没错就重新启动httpd服务 /usr/local/apache2/bin/apachectl restart
感谢大家,点赞,收藏,关注,评论!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。