[GH-ISSUE #1448] Add stacktrace to PHP info/warning messages #610

Open
opened 2026-03-04 02:16:24 +03:00 by kerem · 3 comments
Owner

Originally created by @m-ober on GitHub (Apr 7, 2020).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1448

I'm using

$formatter = new LineFormatter();
$formatter->includeStacktraces(true);

For PHP errors (like call to undefined functions) as well as Exceptions, stack traces are now included in the log. But for warnings like

E_WARNING: urlencode() expects parameter 1 to be string, array given

There is no stack trace, which makes it almost impossible to track the problem. Xdebug always shows stack traces, but of course that's only useful when developing.

Originally created by @m-ober on GitHub (Apr 7, 2020). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1448 I'm using ```php $formatter = new LineFormatter(); $formatter->includeStacktraces(true); ``` For PHP errors (like call to undefined functions) as well as Exceptions, stack traces are now included in the log. But for warnings like > E_WARNING: urlencode() expects parameter 1 to be string, array given There is no stack trace, which makes it almost impossible to track the problem. Xdebug always shows stack traces, but of course that's only useful when developing.
Author
Owner

@Seldaek commented on GitHub (May 11, 2020):

I guess maybe this could be done by passing a new ErrorException into the context data in https://github.com/Seldaek/monolog/blob/master/src/Monolog/ErrorHandler.php and adjusting the stack trace generation to ignore the ErrorHandler frame from the stack trace when it is an ErrorException.

<!-- gh-comment-id:626699993 --> @Seldaek commented on GitHub (May 11, 2020): I guess maybe this could be done by passing a `new ErrorException` into the context data in `https://github.com/Seldaek/monolog/blob/master/src/Monolog/ErrorHandler.php` and adjusting the stack trace generation to ignore the ErrorHandler frame from the stack trace when it is an ErrorException.
Author
Owner

@stefanfisk commented on GitHub (Aug 13, 2020):

How about https://www.php.net/manual/en/function.debug-backtrace.php?

<!-- gh-comment-id:673648353 --> @stefanfisk commented on GitHub (Aug 13, 2020): How about https://www.php.net/manual/en/function.debug-backtrace.php?
Author
Owner

@nox-4O4 commented on GitHub (Mar 4, 2025):

But for warnings like

E_WARNING: urlencode() expects parameter 1 to be string, array given

There is no stack trace, which makes it almost impossible to track the problem.

This will probably change in PHP 8.5: https://wiki.php.net/rfc/error_backtraces_v2

<!-- gh-comment-id:2697711014 --> @nox-4O4 commented on GitHub (Mar 4, 2025): > But for warnings like > > > E_WARNING: urlencode() expects parameter 1 to be string, array given > > There is no stack trace, which makes it almost impossible to track the problem. This will probably change in PHP 8.5: https://wiki.php.net/rfc/error_backtraces_v2
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#610
No description provided.