Where can I see nodejs logs after deploying to Google App Engine?
I have deployed nodejs app in google app engine following this tutorial https://github.com/GoogleCloudPlatform/appengine-nodejs-quickstart and it was successful and now I want to check nodejs logs like in development from terminal console. Vms is operated by google, but even if I ssh for them, I don't know where to look for the logs.
source to share
You can read the standard output of a docker container that is being executed by your application by executing docker logs <container id>
in a virtual machine instance. You can get the container id from docker ps
.
No need for SSH on the instance. You can simply get the logs from the Developer Console under Monitoring > Logs
.
source to share
The default logging is really awful. None of my posts console.log
are showing! There are several ways to fix this.
1) Writing logs to a log file.
For example, / var / log / app_engine / custom_logs / applogs.log
https://cloud.google.com/appengine/articles/logging
"Applications for Cloud Protocols and Managed Virtual Machines Applications Using App Engine Managed Virtual Machines should write their own log files to the VM log directory at / var / log / app_engine / custom_logs. These files are automatically collected and available in the Logs Viewer. Custom log files must have a .log or .log.json suffix. If the suffix is -.log.json, the logs must be in JSON format with one JSON object per line. If the suffix is .log, the log entries are treated as plain text. "
2) Use winston with winston-gae .
Create a transport that will send logs for appengine.
3) Use the gcloud-logging module
Too wordy for my liking, but this is another option.
source to share
As @tamberg pointed out in a comment, the easiest option I have found for viewing logs generated by Google App Engine instances with 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 :
- Open the log viewer in the GCP console: https://console.cloud.google.com/logs/viewer?resource=gae_app
- In the first filter drop-down at the top of the page, make sure GAE is selected and select Default Service.
- Use the second drop-down filter list to select only standard output and click OK. This limits the viewer to logs sent to standard output.
- Use the text box above the dropdowns to find the name you used when submitting the form. You should see logs that match your ideas.
source to share