English 中文(简体)
标志 php错误,但并未在浏览器中显示。
原标题:logs php error but not display it in browser

i 希望在浏览器上显示错误记录。

目前发生错误或警告/通知时,就会产生标志,并向浏览器展示错误,但想迫使系统不要向现场访问者展示浏览器中的错误信息,而是为我制造标志。

Thanks

问题回答

• 确保你在你的实验室中拥有这样的东西:

display_errors = Off
error_log = /var/log/php/error.log # Assuming you have /var/log/php directory and it s writable by httpd
error_reporting = E_ALL & ~E_DEPRECATED

Or set them as run-time options with ini_set()

在您的发言稿上加上:

//don t display errors
ini_set( display_errors , 0);
//write errors to log
ini_set( log_errors , 1);
//error log file name
ini_set( log_errors ,  /var/log/php/error.log );

error_reporting(E_ALL);

审判

error_reporting(E_ERROR | E_PARSE);

如果你想要记录习俗错误:

try {
    // your code here
} catch (Exception $e){
    error_log($e->getMessage(), $e->getCode(), $e->getFile().  Line  .$e->getLine());
}

其他使用user4035 度

如果有人想在2023年之后如何做到这一点,那就是一个迅速的说明,那就是,所有<代码>ini_set(<>>>>>的答案只能从执行之日起算。

这意味着,档案馆内产生的错误可能仍被送至浏览器,当然,这些错误可能是最常见的错误。

这方面的通常固定办法,视贵版本的购买力平价和名称的不同而大不相同;但是,这种固定办法总是会变异,包含有php环境的文件;例如,<代码>php.ini。 请将此碎块添加到php.ini 文档中:

display_errors = Off
log_errors = On

这将抑制浏览器的错误,同时使伐木得以存档。 您可能还需要添加以下条目:error_log = 错误_log





相关问题
Separating Business Layer Errors from API errors

The title is horrible, i know; I m terrible at titles on SO here. I m wondering what would be the best way to present unified error responses in a webapi when errors could be raised deep inside the ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

How to tell why a file deletion fails in Java?

File file = new File(path); if (!file.delete()) { throw new IOException( "Failed to delete the file because: " + getReasonForFileDeletionFailureInPlainEnglish(file)); } Is there a ...

Exceptions: redirect or render?

I m trying to standardize the way I handle exceptions in my web application (homemade framework) but I m not certain of the "correct" way to handle various situations. I m wondering if there is a ...

热门标签