3
votes

I'm using GAE PHP. I try to use the script extraction from https://developers.google.com/appengine/docs/php/logs/#sample_code

But nothing happened.... and i don't know what's wrong...

Also, some time, i face this strange error : Fatal error: The request was aborted because it exceeded the maximum execution time. in /base/data/home/runtimes/php/sdk/google/appengine/runtime/RealApiProxy.php on line 50

Does anyone arrived to extract log from GAE PHP ? Thanks for your help. Sebastien

1

1 Answers

0
votes

Here is an example of how to fetch recent log entries with PHP GAE LogService API:

<?php

error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 'On');

require_once 'google/appengine/api/log/LogService.php';

use google\appengine\api\log\LogService;

$options = [
  'start_time' => (time() - (24 * 60 * 60)) * 1e6,
  'end_time' => time() * 1e6,
  'include_app_logs' => true,
];

$logs = LogService::fetch($options);

foreach ($logs as $log) {
  echo '<br/ ><br /> REQUEST LOG';
  echo '<br /> IP: ' . $log->getIp() .
       '<br /> Status: ' . $log->getStatus() .
       '<br /> Method: ' . $log->getMethod() .
       '<br /> Resource: ' . $log->getResource() .
       '<br />';
  $end_date_time = $log->getEndDateTime();
  echo 'Date: ' . $end_date_time->format('c') . '<br />';

  $app_logs = $log->getAppLogs();

  foreach ($app_logs as $app_log) {
    echo '<br/ ><br /> APP LOG';
    echo '<br /> Message: ' . $app_log->getMessage() . '<br />';
    $app_log_date_time = $app_log->getDateTime();
    echo 'Date: ' . $app_log_date_time->format('c') . '<br />';
  }
}