如何将错误和警告记录到文件中? [英] How to log errors and warnings into a file?

查看:94
本文介绍了如何将错误和警告记录到文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何打开所有错误和警告并将其记录到文件中,但是在脚本中设置所有错误和警告(不改变php.ini中的任何内容)。我想定义一个文件名,以便所有的错误和警告都被登录。

How to 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.

推荐答案

使用以下代码: / p>

Use the following code:

ini_set("log_errors", 1);
ini_set("error_log", "/tmp/php-error.log");
error_log( "Hello, errors!" );

然后观看文件:

tail -f /tmp/php-error.log

或更新 php.ini 这个博客条目从2008年。

Or update php.ini as described in this blog entry from 2008.

这篇关于如何将错误和警告记录到文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆