rur2641
rur2641

Reputation: 699

How to print out request to log

I am trying to debug a Laravel web api. I am having trouble printing the request to log:

use Illuminate\ Support\ Facades\ Log;
//...
  function text(Request $request) {
    Log::info(print_r($request, true));
    //...
  }

The preceding code prints over 10 MB to the log. The same line without the "true" parameter prints only the date and time and nothing else. var_dump prints the same. dd does not print anything.

Upvotes: 5

Views: 5189

Answers (2)

newbmiao
newbmiao

Reputation: 61

$request is a object, when u wanna debug, u just wanna show some info of it.

Such as: your request data: $request->input() your upload file: $request->allFiles();

And u also can use Log::error() try make debug info clearer.

Upvotes: 3

crabbly
crabbly

Reputation: 5186

Do this instead:

use Illuminate\ Support\ Facades\ Log;
//...
  function text(Request $request) {
    Log::info($request);
    //...
  }

Upvotes: 5

Related Questions