取消激活PHP错误记录
我刚刚注意到,我在XAMPP中得到的所有PHP错误都存储在一个日志中,它的大小已经为500 MB。我现在想停用日志记录,而不需要在执行时停止报告。我怎样才能做到这一点?取消激活PHP错误记录
在你的PHP文件
ini_set('log_errors', 'off');
或在php.ini的顶部:
log_errors = off
谢谢,那就是我一直在寻找的。是否还有一种方法可以完全禁用它,例如某个配置文件中的标志? – StrikeAgainst
ini_set('display_errors','Off'); – PHPDave
error_reporting(0); – PHPDave
<?php
// Turn off all error reporting
error_reporting(0);
// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
// Report all PHP errors
error_reporting(-1);
// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
?>
那岂不是更好地修复错误? – andrewsi
我仍然想要显示错误,当然。我只是不希望它们再存储在日志文件中。 – StrikeAgainst
然后,只需定期清除文件。有一天,你会很高兴它在那里。你可以删除它,当你产生新的错误时它会被重新创建。 –