zoukankan      html  css  js  c++  java
  • Apache日志轮替规则

    phpstudy开启apache日志并且按照日期划分创建。
    CustomLog "|bin/rotatelogs.exe logs/access_%Y_%m_%d.log 86400 480" combined

    这里修改成上图所示,然后重启apache。

     
     
    linux : |/usr/local/sbin/cronolog /web/apache/logs/%Y%m%daccess_log 
     

    <IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i""
    LogFormat "%h %l %u %t "%r" %>s %b" common

    <IfModule logio_module>
    # You need to enable mod_logio.c to use %I and %O
    LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here. Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    TransferLog "|/usr/local/sbin/cronolog /web/apache/logs/%Y%m%daccess_log"

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    #CustomLog "logs/access_log" combined
    </IfModule>

     
    Apache日志按时间分段记录
    在apache的配置文件httpd.conf中找到
    ErrorLog logs/error_log及CustomLog logs/access_log common
    Linux系统配置方法:
    将其改为
    ErrorLog “| /usr/local/apache/bin/rotatelogs /home/logs/www/%Y_%m_%d_error_log 86400 480″
    CustomLog “| /usr/local/apache/bin/rotatelogs /home/logs/www/%Y_%m_%d_access_log 86400 480″ common
     
    Windows系统下配置方法:
    ErrorLog “|bin/rotatelogs.exe logs/site1/error-%y%m%d.log 86400 480″
    CustomLog “|bin/rotatelogs.exe logs/site1/access-%y%m%d.log 86400 480″ common

    第一次不知道设置480这个参数,导致日志记录时间和服务器时间相差8小时,原来是rotatelogs有一个offset参数,表示相对于UTC的时差分钟数,中国是第八时区,相差480分钟。86400是表示1天。
     
     
    参考链接:http://www.server110.com/apache/201309/1869.html
  • 相关阅读:
    svn更改默认服务启动目录
    centos systemctl指令
    centos 安装mysql
    centos bad ELF interpreter: No such file or directory
    svn 设置post-commit后 报错svn: Can't convert string from 'UTF-8' to native encoding
    windows 下wamp环境3 安装php7
    windows 下wamp环境2 配置之mysql的安装
    windows 下wamp环境1 配置之apache的安装
    IE8 margin: auto 无法居中
    memcache安装
  • 原文地址:https://www.cnblogs.com/xiaozi/p/5888030.html
Copyright © 2011-2022 走看看