-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log output on stdout/stderr garbled by artisan serve #48924
Comments
Thanks @Radiergummi. Would appreciate any help with figuring this out. Maybe @nunomaduro has some ideas as well. |
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
@nunomaduro it would be super helpful to know why log messages are being split there, is that intended for something emitted by the PHP HTTP server itself? If that isn't resolvable, maybe we could include a Monolog processor in the default |
So I found something of a solution: https://gist.github.com/Radiergummi/beb80325543c5b8bcd611f7229d3608a Essentially wrapping the log formatter used in the I'm aware this issue probably isn't high priority, but I'm happy to contribute a PR. Pretty sure we should try to come up with a better way of handling process output, however :) |
@Radiergummi you could always try to PR it to see what Taylor thinks 👍 |
A PR was merged for this, thanks. |
Laravel Version
10.30.1
PHP Version
8.2.7
Database Driver & Version
Not applicable
Description
When using
php artisan serve
and configuring the logger to write to STDOUT or STDERR (which is pretty common in containerised environments), all application output is split by the character sequence]
(probably expecting a specifically formatted message) and limited to the second segment. This happens in ServeCommand.php on line 290.Unfortunately, this breaks while reporting even builtin errors such as
BindingResolutionException
s, which have the message"Target [$concrete] is not instantiable."
, containing the culprit sequence.And if you start printing debug output to the console, this happens even more often, leading to confusing and only partially printed output.
This breaks several assumptions about framework configuration:
stderr
out of the boxIt is really annoying to be unable to log output on the command line in local development. The only real alternative would be using php-fpm or similar (with nginx in front of it), or Octane; both of them making the stack considerably more complex than necessary.
I think it's reasonable to expect pretty server output not to interfere with user log output. To solve this issue, the
serve
command should not make assumptions about the formatting of process output. I have no clue what the idea of that particularexplode
call was, but at minimum it should probably limit the number of split operations to two:But ideally, the output should be printed verbatim. If that sequence does something special with the default settings, maybe use a better (unique) suffix, or check log settings -- but don't break my output.
This is related to #44781.
Steps To Reproduce
stderr
channel inconfig/logging.php
:]
or cause a binding exception on purpose:php artisan serve
, trigger the code containing 2. and observe the log output:The text was updated successfully, but these errors were encountered: