I tested PsrBatchLogger with the example code in the doc, but it complains:
PHP message: [ERROR] PHP Exception: No project ID was provided, and we were unable to detect a default project ID. Stack Trace: #0 /app/vendor/google/cloud-core/ClientTrait.php(81): Google\Cloud\Logging\LoggingClient->detectProjectId(Array) #1 /app/vendor/google/cloud-logging/LoggingClient.php(124): Google\Cloud\Logging\LoggingClient->configureAuthentication(Array) #2 /app/vendor/google/cloud/src/Logging/PsrBatchLogger.php(134): Google\Cloud\Logging\LoggingClient->__construct(Array) #3 /app/vendor/google/cloud/src/Logging/PsrLoggerTrait.php(255): Google\Cloud\Logging\PsrBatchLogger->getLogger() #4 /app/vendor/google/cloud/src/Logging/PsrLoggerTrait.php(201): Google\Cloud\Logging\PsrBatchLogger->validateLogLevel('info') #5 /app/vendor/company/aura/Error.php(273): Google\Cloud\Logging\PsrBatchLogger->log('info', 'This is a info ...') I did try to init PsrBatchLogger like: $batchLogger = new PsrBatchLogger('app', array('clientConfig' => array('project_id' => 'my-project-id'))); But it doesn't work. On Wednesday, May 31, 2017 at 4:55:09 PM UTC-7, Yao Li wrote: > > I tried Monolog and it is super fast (stdout in example), but it has > logging line by line and no severity, time and status code info like > original gcloud logging under one request, is there any way to achieve that > with Monolog? > > On Tuesday, May 30, 2017 at 11:24:01 PM UTC-7, Takashi Matsuo (Google) > wrote: >> >> Hi Yao, >> >> On Tue, May 30, 2017 at 9:39 PM Yao Li <y...@sazze.com> wrote: >> >>> > I think you can just use other PSR compliant logger, rather than using >>> the PsrBatchLogger on your local machine. >>> >>> Could you give me some examples for other PSR compliant logger? >>> >> >> Monolog? >> >> ``` >> composer require monolog/monolog >> ``` >> >> ``` >> <?php >> >> require_once __DIR__ . '/vendor/autoload.php'; >> >> use Monolog\Logger; >> use Monolog\Handler\StreamHandler; >> use Monolog\Formatter\LineFormatter; >> >> $handler = new StreamHandler('php://stdout'); >> $handler->setFormatter(new LineFormatter(null, null, false, true)); >> >> $logger = new Logger('LocalLogger', [$handler]); >> >> $logger->info('test'); >> ``` >> >> >> >> >>> >>> > Is this happening on App Engine Flex production server, or locally? >>> .... >>> >>> It's on App Engine Flex production server. (I used my project id instead >>> of 'app', but it still complains, what's appropriate way to set the name? >>> just 'app' or 'projects/project-id/log/ID' as suggested? >>> >> >> No you should be able to just set 'app', and it should just work. I can >> not reproduce your issue. Is it possible to somehow share your project so >> that i can repro? >> >> >>> >>> my code: >>> >>> $batchLogger = new PsrBatchLogger('app'); // logName `app`, tried both >>> 'app' and 'my-project-id' >>> >>> >>> >>> $batchLogger->log(LogLevel::DEBUG, 'This is a debug log'); >>> >>> $batchLogger->debug('This is a debug log'); // The same thing >>> >>> >>> > The new logging library will automatically add some useful metadata >>> (monitored resources, trace id, severity). They look very nice to me on the >>> logging UI, but what do you mean exactly by making the format pretty? >>> >>> I mean there are a lot of logging separated in multiple lines (as >>> following example) rather than list under a request like your screenshot. >>> >> >> I think your app is still emitting the logs to stderr, and you are seeing >> the logs on stderr which is not very well formatted. >> >> Once the new logger starts working, your logs will be available in the >> `app` logs. Note that you need to explicitly choose `app` in the log >> dropdown. >> >> -- Takashi >> >> >>> >>> - 2017/05/31 04:19:51 [error] 51#0: *1586 FastCGI sent in stderr: "PHP >>> message: [INFO] Array >>> >>> - ( >>> >>> - [deviceId] => 0...C >>> >>> - [key] => 6....4 >>> >>> - [userId] => 1602 >>> >>> - ) >>> >>> >>> >>> >>> On Thursday, May 25, 2017 at 3:36:25 PM UTC-7, Yao Li wrote: >>>> >>>> I have an app is built on GAE Flex Custom env (GCloud PHP Ngnix docker >>>> image based), I want to improve the application logging format. >>>> >>>> >>>> How can I make the application log format better (more readable, with >>>> timestamp, POST/GET method name, status code (200), size (22 B), time >>>> (4ms), browser(chrome) in one line, put stack trace together instead of >>>> multiple lines now) like GAE logging format? >>>> >>>> >>>> All of the following logs are from Google Cloud Platform Console, Logging >>>> page/tab. >>>> >>>> >>>> >>>> (GAE default logging:) >>>> >>>> >>>> 15:21:23.667POST20022 B4 msChrome 56/User/isHuman >>>> >>>> >>>> (my application log, I want to collect following lines into one part like >>>> above default one rather than multi lines:) >>>> >>>> >>>> 15:21:27.0002017/05/25 22:21:27 [error] 23#23: *34128 FastCGI sent in >>>> stderr: "PHP message: [WARN] jsVersion does not match:3617 3623 >>>> >>>> 15:21:27.000 Stack Trace: >>>> >>>> 15:21:27.000Array >>>> >>>> 15:21:27.000( >>>> >>>> 15:21:27.000[0] => Array >>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Google App Engine" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to google-appengi...@googlegroups.com. >>> To post to this group, send email to google-a...@googlegroups.com. >>> Visit this group at https://groups.google.com/group/google-appengine. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/google-appengine/366a25f6-6fd1-47ae-b4fb-bb6f5cbe7982%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/google-appengine/366a25f6-6fd1-47ae-b4fb-bb6f5cbe7982%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- >> -- Takashi >> > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscr...@googlegroups.com. To post to this group, send email to google-appengine@googlegroups.com. Visit this group at https://groups.google.com/group/google-appengine. To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/d36ffc67-3ef2-4686-acd1-51b679046fb4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.