利用rotatelogs进行apache的日志切割服务

1. 打开apache的虚拟主机配置日志
[root@localhost ~]# vim /usr/local/httpd/conf/extra/httpd-vhosts.conf
# If you want to maintain multiple domains/hostnames on your
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# 
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any  block.
#

    ServerAdmin [email protected]
    DocumentRoot "/usr/local/httpd/htdocs/discuz/"
    ServerName www.discuz.com
    ServerAlias discuz.com
    ErrorLog "/usr/local/httpd/logs/error_log"
    CustomLog "| /usr/local/httpd/bin/rotatelogs /usr/local/httpd/logs/access_%Y%m%d.log 86400 480" combined

2.主要修改文件如下:

利用httpd自带的命令rotatelogs进行日志分割

CustomLog "| /usr/local/httpd/bin/rotatelogs /usr/local/httpd/logs/access_%Y%m%d.log 86400 480" combined
3. rotatelogs命令解析:

官方主页:http://httpd.apache.org/docs/2.4/programs/rotatelogs.html

你可能感兴趣的:(利用rotatelogs进行apache的日志切割服务)