Laravel request logger snippet

Published under Laravel.

Here's a quick snippet to get HTTP request logging setup quickly in Laravel:

Because both the handle and terminate methods access the $this->startTime variable, we need to make sure we receive the same instance of the middleware in both methods. To do this, you need to register the middleware as a singleton in the boot method of your AppServiceProvider:

Don't forget to add the middleware to the $middleware array in App\Http\Kernel.php!

Credit to for some of the lines.

Thanks for reading!

Did you find this post useful? Let me know on Twitter! If you found an issue with the content, submit a pull request!

Subscribe to my newsletter to know when I publish more content in the future.

❤️ Likes: 0
📣 Retweets: 0
💬 Replies: 0
🙊 Mentions: 0