As a response to my other post, as I use Google Cloud Run in production.
- It's not exactly in the LOGS tab. You have to open Log viewer's page
- JSON-like strings will be auto-transformed to JSON inside
jsonPayload. Therefore, you can search like this,
severity>=DEFAULT
jsonPayload.req.method = "GET"
- JSON strings are easier to log, therefore
req.bodyandPOST/PUT/PATCHas easier to log thanreq.queryinGET/DELETE; however, it isn't impossible to pre-transform.- Another problem is
req.query's serialization isn't very standardized. I use currently use rison-node. - I use
GETrequests for potential caching. But I didn't do any caching yet. Also, someGETare truly dynamic (e.g./api/:dict/random).
- Another problem is
export const logger = pino({
serializers: {
req(req) {
return {
method: req.method,
url: req.url,
version: req.headers['accept-version'],
hostname: req.hostname,
remoteAddress: req.ip,
query: parseQuery(req.query),
}
},
},
})
- At least in Fastify, you have to decide what to log, as by default, the logger doesn't log
req.body. (It does logreq.url, therefore, unparsed querystrings.)

Top comments (0)