title: Configure PHP Monolog to log to Amazon S3 via stream
body: <p>We're using Monolog to log output from our server side PHP worker scripts, that execute on Amazon Elastic Beanstalk EC2 server instances. It's rather hard to access log files, especially considering that servers start up and shut down as scaling demand changes.</p>
  
  <p>How can I configure Monolog to log directly to an Amazon S3 stream/bucket?</p>
  
  <p>So far I'm trying something like this in my Pimple dependency injection definitions:</p>
  
  <pre><code>$this-&gt;container['log'] = function ($c) {
      $logger = new \Monolog\Logger('psd_worker');
      $handler = new \Monolog\Handler\StreamHandler('s3://mybucket/logs/test.log');
      $logger-&gt;pushHandler($handler);
      return $logger;
  };
  </code></pre>
  
  <p>but no log file is appearing on the bucket, neither am I getting any exceptions.</p>
  
  <p>A little test reveals that I can write through s3:// to the S3 bucket:</p>
  
  <pre><code>$stream = fopen("s3://{$bucket}/{$key}", 'w');
  fwrite($stream, 'Hello S3 World!');
  fclose($stream);
  </code></pre>
  
  <p>but I want Monologs logging functions to write to this bucket.</p>