Search code examples
phploggingserversilentphp-7.4

Silence PHP 7.4.8 server request logs "Accepted", "Closing"


After updating from PHP 7.3 to PHP 7.4.8, I have noticed the server has started to log "Accepted", "Closing" for all requests and sometimes: "Closed without sending a request; it was probably just an unused speculative preconnection".

[Wed Aug  5 17:51:27 2020] PHP 7.4.8 Development Server (http://localhost:3000) started
[Wed Aug  5 17:51:37 2020] 127.0.0.1:37788 Accepted
[Wed Aug  5 17:51:37 2020] 127.0.0.1:37792 Accepted
[Wed Aug  5 17:51:37 2020] 127.0.0.1:37788 [200]: (null) /
[Wed Aug  5 17:51:37 2020] 127.0.0.1:37788 Closing

[Wed Aug  5 17:52:02 2020] 127.0.0.1:37808 Closed without sending a request; it was probably just an unused speculative preconnection
[Wed Aug  5 17:52:02 2020] 127.0.0.1:37808 Closing

I would like to know if there is an option to start the server in a "silent" mode, where the logs would contain only info, warnings, and errors.


Solution

  • If you are starting the PHP server yourself, passing it the -q or --no-header argument (Quiet-mode) solved it for me:

    php -q -S 127.0.0.1:8080 index.php
    

    See: https://stackoverflow.com/a/66864545