Log Route calls in Laravel using Middleware

 Reading time ~1 minute

Heads up: this article is over a year old. Some information might be out of date, as I don't always update older articles.


Sometimes when developing a new site or application in Laravel you need to log exactly the route calls in order to track bugs and errors. This operation is straightforward.

First, let’s create a new Middleware

php artisan make:middleware LogRouteMiddleware

Then edit the handle function like the following:


public function handle($request, Closure $next)

    return $next($request);

The fullUrl method logs the full URL including all url and query parameters. You can decide also to log other information, for example:

  • ip() returns the client IP address
  • isJson() determine if the request is sending JSON

Pro-tip: The API documentation for the Request class is available at http://laravel.com/api/5.1/Illuminate/Http/Request.html

Finally in app/Http/Kernel.php you can include your Middleware to the list


protected $middleware = [
comments powered by Disqus

Work on a Laravel Live Site while in Maintenance Mode


Since Laravel 4 there’s a handy feature that allows you to put your site in maintenance mode, providing a …