修改配置文件

[root@localhost ~]# vim /usr/local/apache/conf/httpd.conf

  1. <Files ".ht*">
  2. Require all denied
  3. </Files>
  4. ......
  5. # 按天切割错误日志,86400=2M,480为北京时间差校准
  6. ErrorLog "| /usr/local/apache/bin/rotatelogs -l /var/log/httpd/error_%Y%m%d.log 86400 480"
    <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>

    ......

    # 按天切割访问日志,86400=2M,480为北京时间差校准
    CustomLog "| /usr/local/apache/bin/rotatelogs  /var/log/httpd/access_%Y%m%d.log 86400 480" common

创建日志目录

[root@localhost ~]# mkdir /var/log/httpd

验证日志切割

重启httpd,查看/var/log/httpd目录
image.png
Web访问httpd,查看/var/log/httpd目录
image.png