Below is the log getting printed when an exception occurs in application:
"message" => "Unhandled critical exception occured", "context" => [ "class" => "Flight\Exception\FlightBookingErrorException", "code" => "GATEWAY_ERROR_UNKNOWN_ERROR", "message" => "Booking processing failed due to error at bank or wallet gateway\nGateway Error Code=> \nGateway Error Desc: ", "data" => [], "stack" => [ "#0 /app/app/Http/Controllers/PaymentController.php(25): Flight\Models\Booking\Service" . "->generateTicket('Amul Baby', '99999999999', 9846372618163345, AmericanExpressB)", "#1 [internal function]: Flight\Http\Controllers\PaymentController->processTicket()", "#2 /app/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)", ] ]
In the above code, generateTicket method has four arguments and all the sensitive data(Name, Contact, AccountNumber, Bank Name) is logged.
Is there a way to stop logging of function arguments as part of stack trace?
Maybe you can use custom laravel exception handler app/Exception/Handler.php
.
Something like this:
public function report(Throwable $exception)
{
if ($exception instanceof \Flight\Exception\FlightBookingErrorException) {
// custom code
}
parent::report($exception);
}
https://laravel.com/docs/7.x/errors#report-method
#cmiiw
Thanks for the reply. I want more of a generic approach because there could be many methods which can have sensitive data as function arguments.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community