centos 7.6——Apache日志分割(rotatelogs 分割工具、cronolog分割工具)

centos 7.6——Apache日志分割

rotatelogs 分割工具

[root@localhost opt]# yum -y install httpd
[root@localhost opt]#which rotatelogs
/usr/sbin/rotatelogs

[root@localhost opt]#cd /etc/httpd/conf/
[root@localhost httpd]# vim httpd.conf
ServerName www.kgc.com:80
Listen 192.168.75.134:80
#Listen 80
ErrorLog "| /usr/sbin/rotatelogs -l logs/www.kgc.com-error_%Y%m%d.log 86400"
CustomLog "|/usr/sbin/rotatelogs -l logs/www.kgc.com-access_%Y%m%d.log 86400" combined
[root@localhost httpd]#iptables -F
[root@localhost httpd]#setenforce 0
[root@localhost httpd]# systemctl restart httpd
[root@localhost httpd]# cd /var/log/httpd

[root@localhost httpd]# ll
总用量 20
-rw-r--r--. 1 root root 7395 85 15:35 access_log
-rw-r--r--. 1 root root 4504 85 15:39 www.kgc.com-access_20200805.log
-rw-r--r--. 1 root root 2642 85 15:40 www.kgc.com-error_20200805.log

在这里插入图片描述

cronolog分割工具


[root@localhost opt]# ll
总用量 36
-rw-r--r--. 1 root root 36764 85 14:48 cronolog-1.6.2-14.el7.x86_64.rpm
drwxr-xr-x. 2 root root     6 1031 2018 rh
[root@localhost opt]# rpm -ivh cronolog-1.6.2-14.el7.x86_64.rpm 
警告:cronolog-1.6.2-14.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:cronolog-1.6.2-14.el7            ################################# [100%]

[root@localhost opt]# cd /etc/httpd/conf/
[root@localhost conf]# vim httpd.conf 
[root@localhost conf]# which cronolog
/usr/sbin/cronolog
[root@localhost conf]# vim httpd.conf

ServerName www.kgc.com:80
Listen 192.168.75.134:80
#Listen 80
ErrorLog "| /usr/sbin/cronolog  logs/www.kgc.com-error_%Y%m%d.log "

ErrorLog "| /usr/sbin/cronolog  logs/www.kgc.com-error_%Y%m%d.log "
[root@localhost conf]#cd /var/log/httpd
[root@localhost conf]#systemctl restart httpd
[root@localhost httpd]# ll
总用量 16
-rw-r--r--. 1 root root 7395 85 15:35 access_log
-rw-r--r--. 1 root root 2418 85 17:33 www.kgc.com-access_20200805.log
-rw-r--r--. 1 root root 2642 85 17:33 www.kgc.com-error_20200805.log


在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42099301/article/details/107816733