We use Monolog to record output on our server-side PHP desktop scripts that run on Amazon Elastic Beanstalk EC2 server instances. It’s quite difficult to access the log files, especially considering that the server starts and closes as the scaling requirements change.
How to configure Monolog to directly enter Amazon S3 stream / bucket?
So far, I'm trying to do something similar in my Pimple dependency injection definitions:
$this->container['log'] = function ($c) {
$logger = new \Monolog\Logger('psd_worker');
$handler = new \Monolog\Handler\StreamHandler('s3://mybucket/logs/test.log');
$logger->pushHandler($handler);
return $logger;
};
but the log file does not appear in the bucket and I am not getting any exceptions.
A small test shows that I can write via s3: // to the S3 bucket:
$stream = fopen("s3://{$bucket}/{$key}", 'w');
fwrite($stream, 'Hello S3 World!');
fclose($stream);
but I want the Monologs logging functions to be written to this bucket.