1

Logging SQL queries is widely described, for instance here:

How to get the query executed in Laravel 5?

but I found no infos about how to log the queries along with the query results or errors respectively.

Anyone who can fill the gap?

Thanks,

Armin.

Nimral
  • 657
  • 8
  • 25
  • You can use [Terminable Middleware](https://laravel.com/docs/5.4/middleware#terminable-middleware) to log the queries for the routes you want to log. – Jerodev Aug 09 '17 at 08:29
  • Would you please be a bit more specific? I read the page you linked, but don't see how this could help me with my problem. Probably my questionw asn't clear enough: I look for a way to log all database queries like Q: "Select * from users where id = 1" R: "'id' = '1', 'username' = 'Walter', ...." -or- E: "SQL server error ... not found ..." Logging the queries has already been shown (see my link), logging the responses hasn't, and matching the response to a specific query. That's the info I am after. – Nimral Aug 09 '17 at 08:49

1 Answers1

0

IF you want to debug a query(ies) (based on your comment) there is this option Before the query add

\DB::enableQueryLog();

and after the query you can do a dd or whatever with:

\DB::getQueryLog();

Note: This will debug all of the queries in between the two commands

Maky
  • 521
  • 5
  • 21
  • This wasn't what the OP wanted to know, he wanted to know how to get the results of the query logged. enableQueryLog shows the query statement, not the results of the query. – Michael Ryan Soileau Dec 12 '18 at 18:44
  • @MichaelRyanSoileau I do not agree. In the question clearly states: "but I found no infos about how to log the queries along with the query results or errors respectively". Keywords are "how to log" – Maky Jan 07 '19 at 12:30
  • @Maky The OP states: "along with the query results or errors respectively". Then he lists a website which gives him the same information you gave. So you did not give a valid answer. I'm not downvoting the answer, but be careful. I've been downvoted for not fully answering a question. – Michael Ryan Soileau Jan 08 '19 at 17:18