I was using below code for logging each and every request and response for my API but now it's not working for Laravel 5.2.
I have tried to use https://laravel.com/docs/5.2/middleware#terminable-middleware but not succeed.
use Closure;
use Illuminate\Contracts\Routing\TerminableMiddleware;
use Illuminate\Support\Facades\Log;
class LogAfterRequest implements TerminableMiddleware {
public function handle($request, Closure $next)
{
return $next($request);
}
public function terminate($request, $response)
{
$logFile = 'log.txt';
Log::useDailyFiles(storage_path().'/logs/'.$logFile);
Log::info('app.requests', ['request' => $request->all(), 'response' => $response->getContent()]);
}
}
Can anyone suggest me the solution?