Linux-LNMP-Apache访问日志

访问日志记录用户的每一个请求

vim /usr/local/apache2.4/conf/httpd.conf //搜索LogFormat 定义日志格式,默认使用第二个。

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common

%h 来源ip
%l %u 用户名密码
%t 访问时间
"%r\ 行为
%>s 状态码
%b 大小
"%{Referer}i 浏览器上一次访问的网址是什么,因为你会点下一步,访问各个页面的日志,上一条
%{User-Agent}i 用户代理,访问的软件,那个浏览器,

改日志格式
把虚拟主机配置文件改成如下:

<VirtualHost *:80>
DocumentRoot "/data/wwwroot/www.123.com"
ServerName www.123.com
ServerAlias 123.com
CustomLog "logs/123.com-access_log" combined
</VirtualHost>
Linux-LNMP-Apache访问日志
日志路径: /usr/local/apache/logs/ 可cat查看。
Linux-LNMP-Apache访问日志
重新加载配置文件 -t,graceful
curl -x127.0.0.1:80 -I 123.com
tail /usr/local/apache2.4/logs/123.com-access_log

来源ip, 主机名,访问时间,访问行为,访问域名,http版本,状态码
Linux-LNMP-Apache访问日志

猜你喜欢

转载自blog.51cto.com/13451715/2318164
今日推荐