• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
导航菜单
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx
您的位置:首页 > 服务器 >windows > nginx日志

nginx日志

作者:网友 字体:[增加 减小] 来源:互联网

本文主要包含nginx日志切割,nginx日志分析,查看nginx日志,nginx 日志格式,nginx日志在哪等服务器相关知识,网友希望可以进行参考

log_format

context: http,server

syntax: log_format name 'format string ...';

注:format string可以使用一般变量,也可以使用写入日志那些刻的变量过程变量)

$body_bytes_sent $bytes_sent $connection $msec $pipe $request_length

$request_time $status $time_iso8601 $time_local

其它一些变量

$sent_http_content_range upstream_http_...


access_log

context: http,server,location

syntax: acces_log path [format [buffer=size [flush=time]]] | off

注:

如果不指定format默认使用combined格式;

buffer

默认关闭,如果path中包含变量,则不能使用buffer参数;

使用buffer,必须指定日志format;

使用flush必须使用buffer,作用:在缓存没有填满的情况下,超过flush指定的时间将强制写入到日志文件。

如果设置为off,将关闭继承的access_log参数;

path

0.7.4版本以上,path可以包含变量,但是这样的日志有一定的限制,如下:

worker用户必须有新建文件的权限;

不能使用缓存


open_log_file_cache

功能:缓存频繁使用的日志文件描述符


syntax: open_log_file_cache max=N [inactive=time] [min_uses=N] [valid=time];

open_log_file_cache off;

default: open_log_file_cache off;

context: http, server, location


max
sets the maximum number of descriptors in a cache; if the cache becomes full the least recently used (LRU) descriptors are closed
inactive
sets the time after which the cached descriptor is closed if there were no access during this time; by default, 10 seconds
min_uses
sets the minimum number of file uses during the time defined by the inactive parameter to let the descriptor stay open in a cache; by default, 1
valid
sets the time after which it should be checked that the file still exists with the same name; by default, 60 seconds
off
disables caching

Usage example:

open_log_file_cache max=1000 inactive=20s valid=1m min_uses=2;

总结:

经过测试:访问约5到6次会产生1k的日志文件,如果buffer设置32k,也就是说要访问32*6=192/次才能填满缓存,这个根据实际需要调整配合flush参数使用。

实际生产中,如果需要记录日志,可以使用以下格式:

http {
    open_log_file_cache max=1000 inactive=20s valid=1m min_uses=2;
    server {
        server_name    test.cn;
        access_log /var/log/nginx/test.cn/access.log combined buffer=32k flush=1m;
    }
}


注: 使用以上配置,各站点日志的目录不需要有worker进程用户的创建文件的权限,但是如果使用logs/$server_name.access.log这种配置,则需要创建文件权限。但是使用这种配置不能使用buffer,降低服务器性能。

logs/$server_name.access.log使用该配置时,如果server_name配置了多个参数,取第一个。


=======================================================================


日志切割脚本:

详见:http://sndapk.blog.51cto.com/5385144/1297120


本文出自 “notepad” 博客,请务必保留此出处http://sndapk.blog.51cto.com/5385144/1297051

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • nginx日志
  • nginx日志记录客户端真实ip

相关文章

  • winscp在windows下批处理通过SSH端口上传文件
  • Windows 2003与2008远程连接服务器设置图解
  • win2003/2008 IIS服务器.flv文件不能访问解决办法
  • Hyper-V之VDI基础架构
  • win2008用注册表实现右键取得管理员权限
  • Windows Server 2008不能Ping改为允许的方法
  • Windows 2003 服务器的实用安全设置
  • Win 2003系统不能打开chm文件的问题
  • Win2003哪里下载
  • 关于nginx中的fastcgi_param

文章分类

  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx

最近更新的内容

    • liunx基本命令(shell基础优先级调整)
    • windows中apache php环境配置方法(php.ini 配置)
    • windows2003远程桌面超出最大连接数强制登录方法
    • win2003/2008 IIS服务器.flv文件不能访问解决办法
    • 灵活运用eXeScope打造Windows 2000外观
    • Windows IIS 7.5配置301重定向(URL重写)
    • Windows系统防ARP攻击的几种方法总结
    • Windows2003下预防DDos攻击的注册表设置简单教程
    • VM虚拟机vmware下安装Ghost XP的图文教程
    • liunx的启动过程,介绍

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有