PHP-FPM breaks up stack trace log into separate events
Unfortunately not
PHP-FPM simply logs each line of PHP output as a separate event. There's nothing you can do in/with PHP-FPM to change this.
PHP Code
You'll need to "fix" this in your application (PHP code). There are 3 ways you can influence the way PHP reports errors, and you'll probably want to use all 3:
Register a custom error handler with
set_error_handler()
. This handler is called on all errors exceptE_ERROR
,E_PARSE
,E_CORE_ERROR
,E_CORE_WARNING
,E_COMPILE_ERROR
,E_COMPILE_WARNING
, and most ofE_STRICT
raised in the file whereset_error_handler()
is called.Register a custom exception handler with
set_exception_handler()
. This handler is called when an uncaught exception occurs.Register a custom shutdown function with
register_shutdown_function()
. This function is called after script execution finishes orexit()
is called. This one is useful for detecting errors that are not handled with the error handler.
Log library
I can advise you to have a look at Monolog. It's a PSR-3 complaint logging library which also facilitates what I described above.
In addition it has an impressive list of "handlers" which can write the logs to all sorts of services. Chances are the service you're using now is among them!
Alternative
Another option is to create a proxy script that will read the PHP-FPM log files and buffers lines until a "full event" is gathered. Then writing that as a single entry to the service you're using.
I would advise you not to go this way. Writing such a script can be tricky and is very error-prone. Logging from your application itself is much more stable and reliable.