I am trying to log a request that we are sending via guzzle which is deeply nested (upto 10-11 levels deep to be precise).
Logging the request with Monolog spits out:
Over 9 levels deep, aborting normalization
on the deeply nested attributes.
The code is dead simple
// $requestData being the data I am sending via guzzle.
Log::info("Ekart Booking API:", $requestData);
Is there a way I can increase the Monolog's normalization depth?
You can json_encode it:
Log::info("Ekart Booking API:" . json_encode($requestData));
You can play with this, it will change NormalizerFormatter::$maxNormalizeDepth on every formatters it found (that's maybe not what you want)
if ($logger instanceof \Monolog\Logger) {
foreach ($logger->getHandlers() as $handler) {
if ($handler instanceof \Monolog\Handler\FormattableHandlerInterface) {
$formatter = $handler->getFormatter();
if ($formatter instanceof \Monolog\Formatter\NormalizerFormatter) {
$formatter->setMaxNormalizeDepth(50);
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With