Using Error report of Google Cloud Platform with ExpressJS

Calvin Jeng

I switched my ExpressJS application from Heroku to Google App Engine.
Everything works ok now.
But I am curious about how to debug my application if some exceptions happen on GAE.
On heroku, I can do heroku logs -t to trace the errors. I can check the variable printed by console.error(var) as well.
However, I don't know how to do the same thing on GAE.

I have checked logging of Stack Driver, it seems that it only shows some informations of every HTTP request instead of the detailed logs like heroku.
I have found that there is error report service of Stack Driver. It may what I want.
Here is the tutorial telling us how to setup. But the steps are confusing for me.
Does anyone have the experience to setup the error reporting?
I am finding a more clear steps to setup this.
Thanks a lot and appreciated!

Steren

For Stackdriver Error Reporting:

You can use code similar to the one advised for Google Compute Engine: https://cloud.google.com/error-reporting/docs/setup/compute-engine#send_exception_data

Here is what worked for me using Express and Winston on App Engine flexible environment:

var winston = require('winston');
winston.add(winston.transports.File, { filename: '/var/log/app_engine/custom_logs/my.errors.json' });

var report = function (err, req) {
  var payload = {
    serviceContext: {
      service: 'my service',
    },
    message: err.stack,
    context: {
      httpRequest: {
        url: req.originalUrl,
        method: req.method,
        referrer: req.header('Referer'),
        userAgent: req.header('User-Agent'),
        remoteIp: req.ip,
        responseStatusCode: 500,
      }
    }
  };
  winston.error (payload);
};

// Handle errors
app.use(function (err, req, res, next) {
  report(err, req);
  res.status(500).send(err.response || 'Something broke!');
});

For Stackdriver Logging:

Indeed, the request_log only contains HTTP requests log entries on App Engine flex. Look in the stdout log to see the output of your application.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Google cloud platform | 100% API error rate when using google translation API

From Dev

Propagating Error messages in Google Cloud Platform (GCP)

From Dev

Google cloud AI platform error in executing job

From Dev

Docker image run error on Google Cloud Platform

From Dev

How to redeploy google cloud platform using kubectl

From Dev

Invalid Credentials using Google Cloud Platform Buckets

From

Using Buckets in Google Cloud Platform with Golang

From Java

Suspend Google Cloud Platform instance using Java

From Dev

Using the Google Cloud Platform for deploying React applications

From Dev

Sending emails using sendgrid and Google cloud platform

From Dev

Using Google cloud platform to convert speech to text

From Dev

Using Google Cloud Platform for personal use?

From Dev

Error installing fbprophet on Google Cloud Platform AI Platform

From Dev

Internal Server Error when trying to connect to postgres container on Google Cloud Platform using Pgadmin

From Dev

Using Cloud IAM to limit access to App Engine in Google Cloud Platform

From Dev

Simple task queue using Google Cloud Platform : issue with Google PubSub

From Dev

Google Cloud Platform architecture

From Dev

Google Cloud Platform with Firebase

From Dev

Authentication in Google Cloud Platform

From Dev

Error Python API GCP Data Catalog - Google Cloud Platform

From Dev

Google Cloud Platform - receiving a 502 error for a backend not passing health checks

From Dev

Memory allocation error on Google cloud platform VM Instance for Keras Model

From Dev

Google Cloud Platform App Deployment Resulted in 502 Server Error

From Dev

504 error with launching Google Cloud AI Platform Notebook with tensorflow 2.0

From Dev

Google Cloud Platform failure to complete job - permissions error?

From Dev

Memory error in Google Cloud Platform AI Jupyter notebook

From Dev

While creating API Gateway in google cloud platform throwing unreachable error

From Dev

Google Cloud Platform: List available projects using api

From Dev

Creating a bucket using Google Cloud Platform Deployment Manager Template

Related Related

  1. 1

    Google cloud platform | 100% API error rate when using google translation API

  2. 2

    Propagating Error messages in Google Cloud Platform (GCP)

  3. 3

    Google cloud AI platform error in executing job

  4. 4

    Docker image run error on Google Cloud Platform

  5. 5

    How to redeploy google cloud platform using kubectl

  6. 6

    Invalid Credentials using Google Cloud Platform Buckets

  7. 7

    Using Buckets in Google Cloud Platform with Golang

  8. 8

    Suspend Google Cloud Platform instance using Java

  9. 9

    Using the Google Cloud Platform for deploying React applications

  10. 10

    Sending emails using sendgrid and Google cloud platform

  11. 11

    Using Google cloud platform to convert speech to text

  12. 12

    Using Google Cloud Platform for personal use?

  13. 13

    Error installing fbprophet on Google Cloud Platform AI Platform

  14. 14

    Internal Server Error when trying to connect to postgres container on Google Cloud Platform using Pgadmin

  15. 15

    Using Cloud IAM to limit access to App Engine in Google Cloud Platform

  16. 16

    Simple task queue using Google Cloud Platform : issue with Google PubSub

  17. 17

    Google Cloud Platform architecture

  18. 18

    Google Cloud Platform with Firebase

  19. 19

    Authentication in Google Cloud Platform

  20. 20

    Error Python API GCP Data Catalog - Google Cloud Platform

  21. 21

    Google Cloud Platform - receiving a 502 error for a backend not passing health checks

  22. 22

    Memory allocation error on Google cloud platform VM Instance for Keras Model

  23. 23

    Google Cloud Platform App Deployment Resulted in 502 Server Error

  24. 24

    504 error with launching Google Cloud AI Platform Notebook with tensorflow 2.0

  25. 25

    Google Cloud Platform failure to complete job - permissions error?

  26. 26

    Memory error in Google Cloud Platform AI Jupyter notebook

  27. 27

    While creating API Gateway in google cloud platform throwing unreachable error

  28. 28

    Google Cloud Platform: List available projects using api

  29. 29

    Creating a bucket using Google Cloud Platform Deployment Manager Template

HotTag

Archive