In the previous article, you deployed your TypeScript app to Cloud Run.
Cloud Run will capture basic logs based on what you print to stdout
and stderr
, generally what you write using console.log
and console.error
.
After deploying the app, you can use a new gcloud command that's currently in beta to read or even tail your logs.
First, ensure you've got beta support:
gcloud components install beta
Or, if you already had it installed, but just want to update:
gcloud components update
Now you can read your logs:
gcloud beta run services logs read [SERVICE] \
--project=[PROJECT] \
--region=[REGION] \
--limit=10
You should see something like this:
You can also tail your logs:
gcloud beta run services logs tail blogdemo --project javascript-demos
And, of course, now every time you send a request, you'll see a log entry print to your terminal, similar to this:
For the project that you generated in the previous article, update the logs
and logs:tail
scripts in package.json with the values you used for deploy
:
-
[SERVICE]
- the name of your service -
[PROJECT]
- your cloud project ID -
[REGION]
- the region you deployed to
Then you can run either npm logs
or npm logs:tail
.
Next
In the next article, you'll see how you can get more value out of your logs using structured logging, which among other things, will help you correlate logs by HTTP request.
Top comments (0)