nginx日志配置(cookie,header,post等字段记录)
如果你对nginx日志格式,有这样那样的要求。
那么就看一下说明吧。
$remote_addr The remote host
$remote_user The authenticated user (if any)
$time_local The time of the access
$request The first line of the request
$status The status of the request
$body_bytes_sent The size of the server's response, in bytes
$http_referer The referrer URL, taken from the request's headers
$http_user_agent The user agent, taken from the request's headers
如果你想记录某个cookie或者header里面的值的话
$cookie_[COOKIE_NAME]
$http_[HEADER_NAME]
我们来看下面的测试配置:
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user $server_name [$time_local] "$request" '
'$status $body_bytes_sent "$request_body" "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "clickpid=$cookie_clickpid" "clickaid=$cookie_clickaid"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8080;
server_name localhost;
#charset koi8-r;
access_log logs/host.access.log main;
location ~ \.php$ {
#这里会记录post数据
access_log logs/post.log main;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1;
}
location / {
#这里不会记录post数据
root html;
index index.html index.htm;
}
The significance of this variable appears in locations with directives proxy_pass or fastcgi_pass.
只有在用了proxy_pass或者fastcgi_pass标记的location{ }里面变量$request_body才会生效。
可参考:
http://www.cnblogs.com/meteorx/p/3188647.html
另外,还可以参考:
http://articles.slicehost.com/2010/8/27/customizing-nginx-web-logs
日志滚动,可以参考:
http://linux008.blog.51cto.com/2837805/555829/ 使用logrotate
或者手动写脚本crontab 来执行:
#!/bin/sh mv /usr/local/Cellar/nginx/1.6./logs/host.access.log /usr/local/Cellar/nginx/1.6./logs/host.access.log.2015.4.
kill -USR1 `cat /usr/local/var/run/nginx.pid`
sleep
这里mv需要自己判断是否存在重名文件。
nginx日志配置(cookie,header,post等字段记录)的更多相关文章
- nginx日志配置
nginx日志配置 http://www.ttlsa.com/linux/the-nginx-log-configuration/ 日志对于统计排错来说非常有利的.本文总结了nginx日志相关的配置如 ...
- (转)nginx日志配置指令详解
这篇文章主要介绍了nginx日志配置指令详解,nginx有一个非常灵活的日志记录模式,每个级别的配置可以有各自独立的访问日志,需要的朋友可以参考下日志对于统计排错来说非常有利的.本文总结了nginx日 ...
- Nginx https加密以及nginx日志配置与管理
Nginx https加密以及nginx日志配置与管理 使用Nginx的优点Nginx作为WEB服务器,Nginx处理静态文件.索引文件.自动索引的效率非常高.Nginx作为代理服务器,Nginx可以 ...
- nginx日志配置指令详解
这篇文章主要介绍了nginx日志配置指令详解,nginx有一个非常灵活的日志记录模式,每个级别的配置可以有各自独立的访问日志,需要的朋友可以参考下日志对于统计排错来说非常有利的.本文总结了nginx日 ...
- 死磕nginx系列-nginx日志配置
nginx access日志配置 access_log日志配置 access_log用来定义日志级别,日志位置.语法如下: 日志级别: debug > info > notice > ...
- 03 . Nginx日志配置及日志切割
Nginx日志 日志对于统计排错来说是非常有利的,Nginx日志主要分为两种: access_log(访问日志)和error_log(错误日志),通过访问日志可以得到用户的IP地址.浏览器的信息,请求 ...
- 004.Nginx日志配置及状态监控
一 Nginx请求简介 1.1 请求头部 对于HTTP而言,客户端负责发起request请求,服务端负责response响应. request:包括请求行.请求头部.请求数据: response:包括 ...
- Nginx日志配置及日志分析脚本案例
https://blog.csdn.net/bbwangj/article/details/82186162 nginx的log日志分为access log 和 error log 其中access ...
- nginx日志配置[转]
* * * sh /home/zyf/sh/cut_nginx_log.sh 这样就每天的0点1分把nginx日志重命名为日期格式,并重新生成今天的新日志文件。 日志对于统计排错来说非常有利的。本文 ...
随机推荐
- 利用|,&,^,~,<<,>>>写出高效艺术的代码
简单介绍: 大家在阅读源代码的时候常常会看到一些比方以下这样特别难理解的代码. cancelEvent.setAction(MotionEvent.ACTION_CANCEL | (motionEve ...
- Odoo 8.0 new API 之constrains装饰
constrains装饰用于对字段进行限制 应用举例: 定义列: age = fields.Integer(string="age") 方法: @api.constrains('a ...
- exit会结束一个进程
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include<stdlib.h ...
- Nginx配置proxy_pass转发的/路径
请求原地址 :http://servername/static_js/test.html location ^~ /static_js/ { proxy_cache js_cache; proxy_s ...
- 判断gridView是否有数据
我这里的gridView是采用空模板数据来显示的 当gridView的数据源为空的时候它们就会显示标题 有数据的显示它们就会显示下面的这种 你仔细观察会发现,当有数据的时候空标题的table没有了,解 ...
- 第二百六十九节,Tornado框架-Session登录判断
Tornado框架-Session登录判断 Session需要结合cookie来实现 Session的理解 1.用户登录系统时,服务器端获取系统当前时间,进行nd5加密,得到加密后的密串 2.将密串作 ...
- Throw是一个语句,用来做抛出例外的功能
当我们自己定义一个例外类的时候必须使其继承excepiton或者RuntimeException. Throw是一个语句,用来做抛出例外的功能. 而throws是表示如果下级方法中如果有例外抛出,那么 ...
- 对于try catch放在能够很好地处理例外的位置
Exception有一个message属性.在使用catch的时候可以调用: Catch(IOException e){System.out.println(e.message())}; Catch( ...
- phalcon下拉列表
<?php echo Phalcon\Tag::selectStatic("gender", array(0 => "Male", 1 => ...
- ThinkPHP整合短信通知功能
1.使用的“云之讯”云通讯的接口,注册,登录. 地址:http://www.ucpaas.com/ 2. 3. 4. 5.按规范与实际需求,填写相应的信息,注意要审核通过! ------------- ...