Created
October 3, 2016 18:42
-
-
Save Shelob9/174f6093c6b388f325157ba3dea82a46 to your computer and use it in GitHub Desktop.
Log all request to Laravel app. Based on http://blog.phakeapps.com/2015/06/23/log-every-request-and-response-in-laravel-5/ updated for Laravel 5.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace App\Http\Middleware; | |
use Illuminate\Support\Facades\Log; | |
class LogAfterRequest { | |
public function handle($request, \Closure $next) | |
{ | |
return $next($request); | |
} | |
public function terminate($request, $response) | |
{ | |
Log::info('app.requests', ['request' => $request->all(), 'response' => $response]); | |
} | |
} |
Thank you this is incredibly usefull ❤️
You welcome.
…On Tue, Sep 15, 2020 at 5:31 PM GabrieleCicconetti ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Thank you this is incredibly usefull ❤️
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/174f6093c6b388f325157ba3dea82a46#gistcomment-3454816>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANSG6GI2NB4MI3FGPGZQETTSF5JTJANCNFSM4QM4ARUA>
.
--
<https://www.commercepundit.com/>
*Vallabh Kansagara, *Development Technical Leader
[email protected]
Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
terminate
will not work if you are working withDB::beginTransaction();
andDB::commit();
, and if you still wanted to work with it you need to do a rollback or commit before sending a response to the client.I would suggest using bellow code at the
handle
method this will work all time.hope this works for others.