利用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 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# 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 <VirtualHost> block.
#
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    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
</VirtualHost>
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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容