【问题标题】:Deactivating PHP error logging [closed]停用 PHP 错误记录 [关闭]
【发布时间】:2016-02-06 19:02:47
【问题描述】:

我刚刚注意到我在 XAMPP 中遇到的所有 PHP 错误都存储在一个日志中,该日志的大小已经为 500 MB。我现在想停用日志记录,而不是在执行时实际停止报告。我怎样才能做到这一点?

【问题讨论】:

  • 修复错误不是更好吗?
  • 当然,我仍然希望显示错误。我只是不想再将它们存储在日志文件中。
  • 然后定期清除文件。有一天你会很高兴它在那里。你可以删除它,当你产生新的错误时它会重新创建。

标签: php logging compiler-errors xampp reporting


【解决方案1】:

在你的 php 文件的顶部

ini_set('log_errors', 'off');

或在您的 PHP.ini 中:

log_errors = off

【讨论】:

  • 谢谢,这就是我想要的。是否还有一种方法可以完全停用它,例如某些配置文件中的标志?
  • ini_set('display_errors','Off');
  • 我的意思只是记录,而不是在我的代码中停用它,而是在 Xampp 附带的某些文件中,比如 httpd.conf 或类似的东西。我确定某处有一个标志,但我找不到它。
  • 编辑 \YourPathTo\xampp\php\php.ini 并设置 log_errors = off
【解决方案2】:
    <?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);

?>

【讨论】:

    猜你喜欢
    • 2012-05-22
    • 1970-01-01
    • 1970-01-01
    • 2013-03-15
    • 1970-01-01
    • 2017-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多