返回列表 发帖

彻底删除WDCP日志

一、关闭nginx和apache的Web访问日志
默认的Web访问日志关闭会提高性能
如果针对站点开了日志(默认是关闭的),还是会有的,但默认目录是在/www/web_logs
1、nginx的关闭方法:
sed -i '/log_format/a\ access_log off;' /www/wdlinux/nginx/conf/nginx.conf

注:如果WDCP后台运行该命令时提示:
{"errCode":"1","msg":"不支持复杂命令"}

请手动修改www/wdlinux/nginx/conf/nginx.conf文件:
在http段中加一行

access_log off;

2、apache的关闭方法:
sed -i 's#CustomLog "logs/access_log" common#CustomLog /dev/null common#' /www/wdlinux/apache/conf/httpd.conf

手动修改方法:
/www/wdlinux/apache/conf/httpd.conf中:

CustomLog "logs/access_log" common
修改为:
CustomLog /dev/null common

二、降低错误日志记录级别
1、降低nginx错误日志记录级别:
www/wdlinux/nginx/conf/nginx.conf中:
error_log  logs/error.log  notice;
修改为:
error_log  logs/error.log  crit;

  1. error_log 级别分为 debug, info, notice, warn, error, crit  默认为crit, 该级别在日志名后边定义格式如下:
  2. error_log  /your/path/error.log crit;  
  3. crit 记录的日志最少,而debug记录的日志最多。如果你的nginx遇到一些问题,比如502比较频繁出现,但是看默认的error_log并没有看到有意义的信息,那么就可以调一下错误日志的级别,当你调成error级别时,错误日志记录的内容会更加丰富。
复制代码

2、降低apache错误日志记录级别:
/www/wdlinux/apache/conf/httpd.conf
,找到如下内容:
#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn


其中,LogLevel用于调整记于错误日志中的信息的详细程度。(参阅ErrorLog指令)。可以选择下列级别,依照重要性降序排列:
  1. Level Description Example

  2. emerg 紧急 – 系统无法使用。 “Child cannot open lock file. Exiting”

  3. alert 必须立即采取措施。 “getpwuid: couldn’t determine user name from uid”

  4. crit 致命情况。 “socket: Failed to get a socket, exiting child”

  5. error 错误情况。 “remature end of script headers”

  6. warn 警告情况。 “child process 1234 did not exit, sending another SIGHUP”

  7. notice 一般重要情况。 “httpd: caught SIGBUS, attempting to dump core in …”

  8. info 普通信息。 “Server seems busy, (you may need to increase StartServers, or Min/MaxSpareServers)…”

  9. debug 出错级别信息 “Opening config file …”
复制代码
默认级别是warn,那么warn级别以上的日志都会记录,会产生大量“文件不存在”的error级别的错误日志。建议使用 crit 级别的设置,这样只记录致命级别以上的日志,有效减少日志数量。
把LogLevel warn更改为LogLevel crit。
三、删除已生成的日志
1.进入WDCP后台-系统设置-点击关闭web默认日志;  
2.进入WDCP日志目录:  
  cd /www/wdlinux/nginx/logs
删除access.log和error.log:
  rm -rf access.log
  rm -rf error.log


  cd /www/wdlinux/apache/logs
删除access_log和error_log:
  rm -rf access_log
  rm -rf error_log

四、后台“重启WEB”或ssh执行:
/etc/init.d/nginxd restart
/etc/init.d/httpd restart



查看磁盘占用情况,判断WDCP日志是否关闭成功。
欢迎光临:逐梦论坛

查找大文件并删除

查找100M以上的文件:
find / -size +100M |xargs ls -lh

用cat命令重写这几个大的日志文件:
cat /dev/null > /www/wdlinux/nginx-1.0.15/logs/access.log
cat /dev/null > /www/wdlinux/nginx-1.0.15/logs/error.log
cat /dev/null > /www/wdlinux/httpd-2.2.22/logs/error_log
cat /dev/null > /www/wdlinux/httpd-2.2.22/logs/access_log
欢迎光临:逐梦论坛

TOP

其它

nginx
将Httpd.conf 配置文件中的ErrorLog 参数改为下面的,就可以将日志按每天生成一个日志文件.
ErrorLog “|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 1M”
ErrorLog “|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 86400″

关闭访问日志:
在httpd.conf文件中,有如下一行,删除了就不产生日志了,如:
#CustomLog "logs/access_log" common

这一行可能因你的配置不同有所修改,不一定完全相同。搜索一下就能定位到。方法就这么简单吧。最后记得要重启web服务(不用重启vps服务器)才有效。
欢迎光临:逐梦论坛

TOP

返回列表

Powered by Discuz! 7.2   论坛QQ群:逐梦论坛群

© 2001-2021 Comsenz Inc. 鲁公网安备 37120302000001号