限制 Apache日志文件大小的方法

softyun3年前云服务器37

通常我们是在{$apache}/conf/httpd.conf中设置Apache的参数,然而我们并没有发现可以设置日志文件大小的配置指令,通过参考httpd.apache.org/docs/2.0/programs/rotatelogs,可以用apache 自己的程序 rotatelogs.exe(位于 {$apache}/bin/目录下),来限制日志文件的大小。
Usage: rotatelogs [-l] [offset minutes from UTC] or
Add this:
TransferLog "|rotatelogs /some/where 86400"
or
TransferLog "|rotatelogs /some/where 5M"
to httpd.conf. The generated name will be /some/where.nnnn where nnnn is the system time at which the log nominally starts (N.B. if using a rotation time, the time will always be a multiple of the rotation time, so you can synchronizecron scripts with it). At the end of each rotation time or when the file size is reached a new log is started.
在 Windows 下的设置例子如下:
# 限制错误日志文件为 1M
ErrorLog "|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 1M"
# 每天生成一个错误日志文件
#ErrorLog "|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 86400"
# 限制访问日志文件为 1M
CustomLog "|bin/rotatelogs.exe -l logs/access-%Y-%m-%d.log 1M" common
# 每天生成一个访问日志文件
#CustomLog "|bin/rotatelogs.exe -l logs/access-%Y-%m-%d.log 86400" common
linux/Unix下 应该类似。

免责声明:本文内容来自用户上传并发布,站点仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请核实广告和内容真实性,谨慎使用。

相关文章

VPS CentOS-6 下 LNMP HTTP web服务器的搭建步骤

笔者于昨天新入手了一个 vps, 来作为个人博客wid实验室(widlabs)开发的实验环境。所以在这篇博文中, 将介绍 centos 6 下 lnmp http 环境的搭建, 从使用 ssh 登录v...

企业租用高防服务器有什么原因

企业租用高防服务器的原因有:1、高防服务器的防御性高,能够防御DDOS、CC攻击等网络攻击;2、高防服务器是具备较高安全性和稳定性的设备,能够保障企业所有网站的稳定性;3、高防服务器更符合成本需求,其...

低价美国服务器建站如何选择操作系统

低价美国服务器建站选择操作系统的方法:1、根据建站程序选择操作系统,注意Linux系统不支持ASP语言和不兼容access数据库;2、根据系统的稳定性选择操作系统,一般Linux系统比Windows系...

海外多ip服务器怎么进行数据备份

海外多ip服务器进行数据备份的方法:1、应用程序备份,如Plesk、cPanel等,比较方便;2、RAID功能备份,数据恢复速度快,安全性高;3、R1Soft功能备份,是通过读取和扫描来保留数据,海外...

国外云服务器使用CN2带宽的好处有哪些

国外云服务器使用CN2带宽的好处:1. 国外云服务器使用CN2带宽解决ISP之间数据交换问题,实现线路互通互访。2. 国外云服务器采用CN2带宽有利于提高浏览者的访问体验,网络延迟低且速度快。3. 国...

如何提高VPS安全性

提高VPS安全性的方法:1、定期对VPS漏洞进行扫描,及时发现并进行处理,防止被黑客轻易利用发起攻击;2、给VPS部分重要的端口进行更换,避免黑客轻易扫描发现进行攻击;3、给VPS安装安全软件,提高服...