my purpose is to manage the logs of my application with Google Stackdriver. The application is a lumen 5.8. Actually it works locally, but if deployed on my Google App Engine application it doesn't give back any error, but no logs are reported. There the steps:
composer require google/cloud
<?php
namespace App\Logging;
use Google\Cloud\Logging\LoggingClient;
use Monolog\Handler\PsrHandler;
use Monolog\Logger;
class CreateStackdriverLogger
{
/**
* Create a custom Monolog instance.
*
* @param array $config
* @return \Monolog\Logger
*/
public function __invoke(array $config)
{
putenv('GOOGLE_APPLICATION_CREDENTIALS=' . config('google.service_account.filepath'));
$logger = LoggingClient::psrBatchLogger('app');
$handler = new PsrHandler($logger);
return new Logger('stackdriver', [$handler]);
}
}
<?php
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;
use App\Logging\CreateStackdriverLogger;
return [
'channels' => [
'stackdriver' => [
'driver' => 'custom',
'via' => CreateStackdriverLogger::class,
'level' => 'debug',
],
...
$app->configure('logging');
What am I doing wrong?
Got it. The problem was in my php.ini :
extension=grpc.so
extension=protobuf.so
extension=mongodb.so
removing grpc.so and protobuf.so it turned back to work properly