Setting up on App Engine Flexible Environment

Error Reporting is automatically enabled for App Engine flexible environment applications. No additional setup is required. Errors written to stderr (which App Engine is configured by default to write to) are analyzed and displayed by the Error Reporting service.

See Viewing Errors for instructions on viewing error and exception data for your application in the Cloud Platform Console.

Examples using the instrumentation libraries

If you'd like to customize the error information being sent to Error Reporting, you can use the instrumentation libraries available for a number of languages.


Refer to the README for deployment instructions.

'use strict';

const express = require('express');
const errors = require('@google-cloud/error-reporting')();

const app = express();

app.get('/', (req, res, next) => {
  next(new Error('something is wrong!'));

app.use((err, req, res, next) => {;
  res.status(500).send(err.message || 'Something broke!');

const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
  console.log(`App listening on port ${PORT}`);
  console.log('Press Ctrl+C to quit.');


Refer to the README for deployment instructions.

// Imports the Google Cloud client library
use Google\Cloud\Logging\LoggingClient;

// These variables are set by the App Engine environment. To test locally,
// ensure these are set or manually change their values.
$projectId = getenv('GCLOUD_PROJECT') ?: 'YOUR_PROJECT_ID';
$service = getenv('GAE_SERVICE') ?: 'error_reporting_quickstart';
$version = getenv('GAE_VERSION') ?: '1.0-dev';

// Instantiates a client
$logging = new LoggingClient([
    'projectId' => $projectId

// The name of the log to write to
$logName = 'my-log';

// Selects the log to write to
$logger = $logging->logger($logName);

$handlerFunction = function (Exception $e) use ($logger, $service, $version) {
    // Creates the log entry with the exception trace
    $entry = $logger->entry([
        'message' => sprintf('PHP Warning: %s', $e),
        'serviceContext' => [
            'service' => $service,
            'version' => $version,
    // Writes the log entry

    print("Exception logged to Stack Driver Error Reporting" . PHP_EOL);

// Sets PHP's default exception handler

throw new Exception('This will be logged to Stack Driver Error Reporting');


Refer to the README for deployment instructions.

To install the agent:

pip install --upgrade google-cloud-error-reporting

from import error_reporting

def simulate_error():
    client = error_reporting.Client()
        # simulate calling a method that's not defined
        raise NameError
    except Exception:

Send feedback about...

Stackdriver Error Reporting Documentation