简体   繁体   English

php error_log 在本地环境中不起作用

[英]php error_log not working in local environment

I'm running copy of PHP as a local server under Windows 10.我正在运行 PHP 的副本作为 Windows 10 下的本地服务器。 在此处输入图像描述

I have got a simple test script "t.php":我有一个简单的测试脚本“t.php”:

error_log('one');
ini_set('error_log', 'ttt.log');        // may be also absolute path like c:\ttt.log - does not work either 
error_log('two');
echo 't';

After running that script the second message is sent "to nowhere" - there is no file with the message 'two'.运行该脚本后,第二条消息被发送到“无处” - 没有包含消息“二”的文件。

在此处输入图像描述

Any help, how to get the second message in error_log file?任何帮助,如何在 error_log 文件中获取第二条消息?

Finally I found what's been wrong.最后我发现出了什么问题。 The problem was caused by Windows 10 file security system, not PHP itself.该问题是由 Windows 10 文件安全系统引起的,而不是 PHP 本身引起的。 Oryginally I started PHP program from.BAT file.最初我从 .BAT 文件启动 PHP 程序。 PHP had no permission to write to any file, so all attempts to write a log file were silently discarded by Windows. PHP 没有写入任何文件的权限,因此所有写入日志文件的尝试都被 Windows 静默丢弃。 After running PHP from.LNK file (shortcut to original file) and assigning administrator privileges in that file - the problem disappeared.从.LNK 文件(原始文件的快捷方式)运行 PHP 并在该文件中分配管理员权限后 - 问题消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM