How to log SQL queries in Laravel

By Faramarz Salehpour

UPDATE[2014-07-17]: Modified the code to fix the problem mentioned by Daniel Walker in comments.

To log SQL queries in Laravel 4, you can put the following code somewhere in your app's structure to run before running queries (e.g. app/filters.php).

Thanks to Shawn McCool.

The output is logged at app/storage/logs/log-cli-.txt

The is a YYYY-MM-DD string which indicates the date of the log. Look for lines starting with log.INFO:.