Skip to content

Instantly share code, notes, and snippets.

@davebarnwell
Forked from Shelob9/LogAfterRequest.php
Created September 1, 2021 08:25
Show Gist options
  • Save davebarnwell/36a9ca38b3e05e0c52a3d54381613249 to your computer and use it in GitHub Desktop.
Save davebarnwell/36a9ca38b3e05e0c52a3d54381613249 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
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]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment