如何将错误和警告记录到文件中? [英] How do I log errors and warnings into a file?
本文介绍了如何将错误和警告记录到文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何打开所有错误和警告并将其记录到文件中,但要在脚本中设置所有错误和警告(不更改php.ini中的任何内容)?
How do I turn on all error and warnings and log them to a file, but to set up all of that within the script (not changing anything in php.ini)?
我想定义一个文件名,以便所有错误和警告都记录到该文件中.
I want to define a file name and so that all errors and warnings get logged into it.
推荐答案
使用以下代码:
ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
error_log( "Hello, errors!" );
然后观看文件:
tail -f /tmp/php-error.log
或按照此博客条目(来自2008年).
Or update php.ini
as described in this blog entry from 2008.
这篇关于如何将错误和警告记录到文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文