LAMP - Apache日志切割
2016-08-06 21:34
204 查看
网站会随着访问量的增大,而造成记录的日志变得越来越大,如果置之不理,总有一天会撑爆磁盘。
所以我们应该每天定时去切割日志,比如一个月之后,再去删除过时的日志,以保证日志文件不会无穷无尽的占用磁盘的资源。
配置:需进入apache的虚拟主机配置文件中,修改ErrorLog & CustomeLog 两行的字段,利用bin目录下的rotatelogs执行文件来进行切割
<VirtualHost *:80>
DocumentRoot "/data/www"
ServerName www.test.com
ServerAlias www.aaa.com www.bbb.com www.ccc.com
ErrorLog "logs/test.com-error_log"
CustomLog "|/usr/local/apache/bin/rotatelogs -l /usr/local/apache/logs/test.com-access_%Y%m%d_log 86400" combined
说明:%Y%m%d 定义日志是按照每天的日期来命名的,86400是指过了86400秒(一天)再进行切割
combined 代表记录日志的格式,具体可以在httpd.conf这个配置文件里查看
<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\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
所以我们应该每天定时去切割日志,比如一个月之后,再去删除过时的日志,以保证日志文件不会无穷无尽的占用磁盘的资源。
配置:需进入apache的虚拟主机配置文件中,修改ErrorLog & CustomeLog 两行的字段,利用bin目录下的rotatelogs执行文件来进行切割
<VirtualHost *:80>
DocumentRoot "/data/www"
ServerName www.test.com
ServerAlias www.aaa.com www.bbb.com www.ccc.com
ErrorLog "logs/test.com-error_log"
CustomLog "|/usr/local/apache/bin/rotatelogs -l /usr/local/apache/logs/test.com-access_%Y%m%d_log 86400" combined
说明:%Y%m%d 定义日志是按照每天的日期来命名的,86400是指过了86400秒(一天)再进行切割
combined 代表记录日志的格式,具体可以在httpd.conf这个配置文件里查看
<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\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
相关文章推荐
- LAMP架构(apache访问日志不记录静态文件,静态元素过期时间,apache日志切割)
- LAMP 2.0Apache日志切割
- LAMP搭建9:Apache日志切割
- apache日志切割
- Apache日志切割
- Apache日志切割及不记录指定类型日志
- apache日志切割
- Apache日志切割shell脚本
- LAMP架构(六)之日志切割和静态元素
- Apache日志按天切割
- apache日志切割与不记录指定文件类型日志
- 2.0-apache日志切割
- Apache日志切割
- LAMP--Apache 日志切割
- apache日志切割
- 企业shell脚本分析及切割apache日志实战 推荐
- apache日志切割
- apache日志切割
- apache日志切割实用入门教程
- apache日志的轮换切割