如何通过 PHP 通过 FastCGI 将任意字符串发送到 STDERR?

How to send arbitrary strings to STDERR via FastCGI wiith PHP?

我希望我的消息直接出现在我的 NginX 错误日志中,例如

2020/06/04 16:23:00 [error] 9057#9057: *26 FastCGI sent in stderr: "MESSAGE" while reading response header from upstream, client: 151.24.155.27, server: "fqdn", request: "GET /page.php HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "hostname"

我知道 PHP 在通过 CLI 执行时可以写入 STDERR,但我指的是网页。

RTFM I guess

这个:

<?php error_log("MESSAGE", 0);?>

结果是这样的:

2020/06/04 16:23:00 [error] 9057#9057: *26 FastCGI sent in stderr: "MESSAGE" while reading response header from upstream, client: 151.24.155.27, server: "fqdn", request: "GET /page.php HTTP/2.0", upstream: "fastcgi://127.0.0.1:9000", host: "127.0.0.1"