Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore.

15 St Margarets, NY 10033
(+381) 11 123 4567



Laravel HTTP Client Logger | Laravel News

HTTP Client Logger is a logger for the built-in Laravel HTTP client. It makes logging the request and response simple by sending it to a configured Laravel logger.

In its simplest form, this Logger package will output the following example log:


//[2021-03-08 06:58:49] local.DEBUG: Time 0.12105202674866sec
//GET /p2/bilfeldt/laravel-http-client-logger.json HTTP/1.1
//User-Agent: GuzzleHttp/7
//Host: repo.packagist.org
//HTTP/1.1 200 OK
//Server: nginx
//Date: Mon, 08 Mar 2021 06:58:49 GMT
//Content-Type: application/json
//Last-Modified: Wed, 17 Feb 2021 14:31:03 GMT
//Transfer-Encoding: chunked
//Connection: keep-alive
//Vary: Accept-Encoding

You can also conditionally log HTTP requests based on a given “truthy” condition using the logWhen() and even supply logging context to both log() and logWhen():

// Log some context along with the HTTP request log
Http::log(['note' => 'Something to log'])->get('https://example.com');

// Log (with context) when $condition === true
Http::logWhen($condition, ['note' => 'Something to log'])

Additionally, this package allows you to pass on-demand logging configuration and even specify a logger for complete HTTP logging flexibility.

This implementation is made possible through the macroable PendingRequest class you can see in action here.

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Credit: Source link

Previous Next
Test Caption
Test Description goes like this