日志-apache的access_log与error_log

1. access_log 访问日志
access_log为访问日志,记录所有对apache服务器进行请求的访问,它的位置和内容由CustomLog指令控制,LogFormat指令可以用来简化该日志的内容和格式 

2. error_log 错误日志
error_log为错误日志,记录下任何错误的处理请求,它的位置和内容由ErrorLog指令控制,通常服务器出现什么错误,首先对它进行查阅, 是一个最重要的日志文件


通过apache配置文件,找到日志存放地址:
find / -name "httpd.conf"
找到配置文件地址,打开它,在里边找到apache的【访问日志】与【错误日志】存放地址

sudo vi /private/etc/apache2/httpd.conf



我的存放地址分别在:
/private/var/log/apache2/error_log
/private/var/log/apache2/access_log


一。查看apache错误日志
tail -f -30  "/private/var/log/apache2/error_log"

[Fri Jan 13 14:32:52 2017] [error] [client 127.0.0.1] client denied by server configuration: /export/home/live/ap/htdocs/test
第一项是错误发生的日期和时间;
第二项是错误的严重性, LogLevel 指令使只有高于指定严重性级别的错误才会被记录;
第三项是导致错误的IP地址;
此后是信息本身,在此例中,服务器拒绝了这个客户的访问。服务器在记录被访问文件时,用的是文件系统路径,而不是Web路径。
错误日志中会包含类似上述例子的多种类型的信息。此外,CGI脚本中任何输出到stderr(标准错误)的信息会作为调试信息原封不动地记录到错误日志中。



二。同样的,在apache配置文件里找到access_log存放地址
tail -f -30  "/private/var/log/apache2/access_log"


看一条典型的access_log的日志记录:
61.155.149.20 - - [13/Jan/2017:15:42:47 +0800] "GET /category/db/ HTTP/1.1" 200 23225

1).61.155.149.20 
这是一个请求到apache服务器的客户端ip,默认的情况下,第一项信息只是远程主机的ip地址,但我们如果需要apache查出主机的名字,可以将 HostnameLookups设置为on,不推荐使用,会大大降低网站速度。

2). -  
这一项是空白,使用"-"来代替,用于记录浏览者的标识,对于大多数浏览器,这项都是空。

3). -  
也为空,记录浏览者进行身份验证时提供的名字,大多数这项也为空。

4). [13/Jan/2017:15:42:47 +0800]
第四项是记录请求的时间,格式为[day/month/year:hour:minute:second zone],最后的+0800表示服务器所处的时区为东八区

5). "GET /category/db/ HTTP/1.1"  
这一项最有用,首先,它告诉我们的服务器收到的是一个GET请求,其次,是客户端请求的资源路径,第三,客户端使用的协议时HTTP/1.1,整个格式为"%m %U%q %H",即"请求方法/访问路径/协议"

6). 200 
这是一个状态码,由服务器端发送回客户端,它告诉我们客户端的请求是否成功,或者是重定向,或者是碰到了什么样的错误,这项值为200,表示服务器已经成 功的响应了客户端的请求,一般来说,这项值以2开头的表示请求成功,以3开头的表示重定向,以4开头的标示客户端存在某些的错误,以5开头的标示服务器端 存在某些错误。

7).23225  
这项表示服务器向客户端发送了多少的字节,在日志分析统计的时侯,把这些字节加起来就可以得知服务器在某点时间内总的发送数据量是多少


本文叙述的是apache下的两种日志访问nginx日志请点击

php错误日志:检测php运行时或用户自记录错误日志: http://blog.csdn.net/ty_hf/article/details/55505262
mysql慢日志:记录mysql服务器中影响性能的SQL: http://blog.csdn.net/ty_hf/article/details/55504172

本文地址:http://blog.csdn.net/ty_hf/article/details/55504719

  • 3
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
帮我看看nginx 的conf配置文件,看看文件有没有错误 ,我想要的效果是请求遇到v1就转发到别的网址。文件内容是:#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location ^~/v1 { proxy_pass https://u91298-ad38-3bb835ff.neimeng.seetacloud.com:6443/api/; } location / { root C:/Users/Administrator/Desktop/chat-cs/dist; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ .php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ .php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }
05-21

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值