zoukankan      html  css  js  c++  java
  • tengine日志切割-配置分钟级别日志自动切割

    tengine日志切割-配置分钟级别日志自动切割

    安装

    以安装最新版本的tengine-2.1.2版本 下载连接

    tengine支持许多变量
    变量
    $conn_requests
    当前请求在长连接上的序号
    $dollar
    表示美元符号本身
    $request_time_msec
    请求处理时间,单位是毫秒,用于log_format中
    $request_time_usec
    请求处理时间,单位是微秒,用于log_format中
    $unix_time
    当前时间戳,其值为1970年1月1日以来的秒数
    $year
    当前4位年(如2011)
    $year2
    当前2位年(如11)
    $month
    当前月份,有前导0(如12)
    $day
    当前日,有前导0(如22)
    $hour
    当前24小时制的小时,有前导0(如21)
    $hour12
    当前12小时制的小时,有前导0(如09)
    $minute
    当前分钟,有前导0(如55)
    $second
    当前秒,有前导0(如12)
    $sent_cookie_XXX
    响应Set-Cookie头中XXX的cookie值
    $host_comment
    主机名和时戳,内容类似于“<!-- localhost Thu, 29 Dec 2011 10:10:56 GMT -->”。

    利用tengine的变量属性,可以做到分钟级别以及秒级别切割日志(使用tengine内置的功能)
    配置如下

    access_log  logs/$year$month$day$hour$minute.access.log  main ;

    之后重启nginx

    [root@dev logs]# ls -l
    total 115320
    -rw-r--r-- 1 www  www  14660146 Aug  3 17:59 201608031759.access.log
    -rw-r--r-- 1 www  www   4140176 Aug  3 18:00 201608031800.access.log
    -rw-r--r-- 1 www  www  14351262 Aug  3 18:08 201608031808.access.log
    -rw-r--r-- 1 www  www   4448738 Aug  3 18:09 201608031809.access.log

    注意到一个情况,在没有日志写入的情况下(没有访问的情况下),不会自动生成新的日志文件

    分类: Linux
  • 相关阅读:
    Python subprocess方法
    Python hashlib、hmac加密模块
    mysql binlog详解
    Nginx 关键字详解
    账号笔记
    Python configparser模块
    Python yaml处理
    Linux && 与 ||
    spring boot 学习(十一)使用@Async实现异步调用
    spring boot 学习(十)SpringBoot配置发送Email
  • 原文地址:https://www.cnblogs.com/qiangyuzhou/p/11007708.html
Copyright © 2011-2022 走看看