您好,我无法访问 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/