AWS PHP SDK logging using Guzzle

Recently I’ve been working on AWS PHP SDK. I found out that there is a simple code snippet to enable wire logging in the API

use Guzzle\Plugin\Log\LogPlugin;

// Create an Amazon S3 client
$s3Client = S3Client::factory();

// Add a debug log plugin

However according to FAQs on the AWS docs site, we have to create our own plugin for logging in a file. I had a look at the code and found that you just have to provide the 2nd parameter to getDebugPlugin function and it wil start logging in the file

// Create an Amazon S3 client
$s3Client = S3Client::factory();

$logPlugin = LogPlugin::getDebugPlugin(TRUE,
  //Don't provide this parameter to show the log in PHP output
  fopen(APPPATH . 'logs/wire.log', 'a')

Later if you want to stop the logging you have to use the following snippet.

//Remove this log plugin to the client

I am a web developer working @ Gaditek

Tagged with: , , , ,
Posted in Amazon, Programming & Development

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

About me
A geek trying to make world a better place to live.

I work on LAMP Stack, SRE and resilience engineering. I also worked on Python, GAE and Netsuite Customization. Currently working @ Cloudways as Software Architect

Profile Links Linkedin | Github | Stackoverflow
Subscribe to this blog
%d bloggers like this: