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日志重命名为日期格式,并重新生成今天的新日志文件。 日志对于统计排错来说非常有利的。本文 ...
随机推荐
- cpython和lua源码阅读
cpython代码很多,不太容易看出来. lua代码真的短小精悍,不得不佩服.
- 问题-Ctrl+F7跟踪值时提示“Function to be called, TGGLPolyhedron3d.AsString, was eliminated by linker”
问题现象:F9运行程序后,选中一个对象,Ctrl+F7跟踪值时,调用对象的某一个方法提示“Function to be called, TGGLPolyhedron3d.AsString, was e ...
- PHP——投票
要求: 选择第一个页面的复选框值,点击提交则提交数据,点击查看结果在同一页面覆盖显示结果的投票人数,百分比和进度条,点击返回,返回第一页面 数据库为 投票 表格为diaoyanxx 表格内容为: zh ...
- 树莓派安装centos 7系统
1,格式化 https://www.sdcard.org/downloads/formatter_4/eula_windows/ 2,烧录,Win32DiskImager https://source ...
- 日期-date.js
Date.prototype.format = function(format) { var o = { "M+" : this.getMonth() + 1, // 月 &quo ...
- 关于Unity的C#基础学习(四)
一.数组 存放同种类型的一组数据,同类+多个 1.定义 int [] int_set; int_set=new int[10]; //在堆上分配出10个int,int_set是数组的引用变量,指向1 ...
- 分享在github超酷超炫特效动画,不看你会懊悔的。
有图有真相直接上效果图,有须要的朋友们能够到连接上去下载. 下载地址:https://github.com/ChrisRenke/DrawerArrowDrawable 下载地址:https://gi ...
- Windows网络接口API函数
Windows提供了一套非常轻量级的网络函数,方便进行网络应用开发,整理出来供参考使用. The following functions are used in Windows networking: ...
- VC++ 设置桌面壁纸
Windows Shell API提供了接口IActiveDesktop来完成墙纸的设置. //IActiveDesktop 接口方法表 (详情参见MSDN) AddDesktopItem AddDe ...
- hdu 2234(IDA*)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2234 思路:IDA*可以搞,借鉴的是大牛的启发式函数h(): 可以考虑把每一行上的数转化成相同的,或者 ...