eloone
eloone

Reputation: 4344

Where can I see the nodejs logs after I deployed on Google App Engine?

I deployed a nodejs app on Google App engine following this tutorial https://github.com/GoogleCloudPlatform/appengine-nodejs-quickstart it was successful and now I want to check the logs of the nodejs server, like in development from the terminal console. The Vms are managed by google but even if I ssh to them I don't know where to look for the logs.

Upvotes: 5

Views: 3148

Answers (3)

kevinmicke
kevinmicke

Reputation: 5058

As @tamberg mentioned in a comment, the easiest option I've found for looking at logs produced by Google App Engine instances running Node.js is to simply use the log viewer at:

https://console.cloud.google.com/logs/viewer?resource=gae_app

Detailed instructions from https://cloud.google.com/appengine/docs/standard/nodejs/building-app/viewing-service-logs are as follows:

  1. Open the Logs Viewer in the GCP Console: https://console.cloud.google.com/logs/viewer?resource=gae_app
  2. In the first filter dropdown at the top of the page, ensure GAE Application is selected, and choose Default Service.
  3. Use the second filter dropdown to select only stdout and click OK. This limits the viewer to logs sent to standard output.
  4. Use the text field above the dropdowns to search for the name you used when you submitted your form. You should see the logs corresponding to your submissions.

Upvotes: 1

posit labs
posit labs

Reputation: 9431

The default logging is really awful. None of my console.log messages show up! There are a few ways you can fix this.

1) Write logs to a log file.

For example, /var/log/app_engine/custom_logs/applogs.log

https://cloud.google.com/appengine/articles/logging

"Cloud Logging and Managed VMs apps Applications using App Engine Managed VMs should write custom log files to the VM's log directory at /var/log/app_engine/custom_logs. These files are automatically collected and made available in the Logs Viewer. Custom log files must have the suffix .log or .log.json. If the suffix is .log.json, the logs must be in JSON format with one JSON object per line. If the suffix is .log, log entries are treated as plain text."

2) Use winston with winston-gae.

Create a transport that will send the logs to appengine.

3) Use gcloud-logging module

Too verbose for my liking, but it is another option.

Upvotes: 0

Martin Kreichgauer
Martin Kreichgauer

Reputation: 36

You can read the stdout of the docker container that your app runs by doing docker logs <container id> in the VM instance. You can get the container id from docker ps.

No need to SSH into the instance though. You can simply fetch the logs from the Developers Console under Monitoring > Logs.

Upvotes: 2

Related Questions