php - 如何在php中仅将所有error_logs写入一个文件

标签 php error-handling

您好,我无法访问 php.ini,我使用这篇文章 How to log errors and warnings into a file?

我在 public_html 中有 23 个文件和 47 个子目录

我想任何地方发生错误或警告所有错误写入 public_html/my_error.log

但现在我在任何子目录中都有一个 error.log 文件

我尝试了这段代码,但这只会更改 public_html 和子目录中的名称日志错误文件

<IfModule mod_php5.c>
php_flag log_errors on 
php_value error_log ./path_to_MY_PHP_ERRORS.log
</IfModule>

谢谢

最佳答案

i not have access to php.ini

error_log ini directive is writable from everywhere ,因此您不需要访问 ini 文件本身。你可以用 ini_set 设置它,例如

ini_set("error_log", "/path/to/your/error.log");

but now i have in any sub directory a error.log file

如果您在每个子目录中都有一个日志文件,您可能指定了一个 relative path instead of an absolute path [error_log()][1] 中的目标参数。举个例子:

error_log("You messed up!", 3, "/var/tmp/my-errors.log");

同样,在 httpd 配置片段中,使用绝对路径:

php_value error_log /absolute/path_to_MY_PHP_ERRORS.log

关于php - 如何在php中仅将所有error_logs写入一个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46782831/

相关文章:

php - 如何使用 php 7 centos 6.5 安装 gd 库

php - 获取每个类别的最后一篇文章

string - haskell-需要整数的字符串

exception - 如何在第一次词法分析错误时退出ANTLR 4?

php - 用对应的口音替换口音

php - 采用 Ruby on Rails 提高产品质量?

json - 处理IE且不处理fileSize等

vba - 为什么同一个Err.Description有多个Err.Number?

javascript - 有没有办法捕获 js 错误但不会因为它们而导致 testcafe 测试失败?

php - 将 doc 转换为 txt