如何停止 php-cli-server 的请求日志记录

时间:2021-06-25 09:54:43

标签: php

我正在使用 php 7.4,我正在尝试使用 php-cli 构建本地开发服务器 我可以在我的路由文件中记录请求,但 php-server 总是记录这样的请求;

[Fri Jun 25 12:49:59 2021] PHP 7.4.20 Development Server (http://localhost:8100) started
[Fri Jun 25 12:50:01 2021] [::1]:51057 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51058 Accepted
[Fri Jun 25 12:50:01 2021] Connection: ::1:51058 [200]: /
[Fri Jun 25 12:50:01 2021] [::1]:51058 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51059 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51060 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51061 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51062 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51063 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51064 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51059 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51060 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51061 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51062 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51063 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51065 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51064 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51066 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51065 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51067 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51066 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51068 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51069 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51067 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51068 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51069 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51070 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51071 Accepted
[Fri Jun 25 12:50:01 2021] [::1]:51070 Closing
[Fri Jun 25 12:50:01 2021] [::1]:51071 Closing
[Fri Jun 25 12:51:01 2021] [::1]:51057 Closed without sending a request; it was probably just an unused speculative preconnection
[Fri Jun 25 12:51:01 2021] [::1]:51057 Closing

[Fri Jun 25 12:50:01 2021] Connection: ::1:51058 [200]: / 部分由路由器记录。 如何关闭其他日志?请帮帮我。

1 个答案:

答案 0 :(得分:0)

一旦我阅读了有关以静默模式启动 php 服务器的信息。我想我们可以使用 -q 标志来避免 php-fpm 带来的请求日志记录。

我正在使用一个小功能启动我的服务器;

function start() {
    exec("php -S address:port .router.php")
}

如果我想使用安静模式,我需要在这个函数中添加 -q 标志。 喜欢;

function start() {
    exec("php -q -S address:port .router.php")
}

这不能解决我的问题。实际上这会杀死每个 error_log() 函数。请寻找其他解决方案。