0

I've been attempting to use different log levels in my App Engine Flexible Node deployment, to no avail.

My first attempt was simply using console.info, console.warn, etc.

I then attempted to use Winston as described in these docs.

app.get('/testlog', (req, res) => {
  // Writes some log entries
  logger.silly('silly');
  logger.debug('debug');
  logger.info('info');
  logger.warn('warn');
  logger.error('error');
  res.send("Logs written")
})

Locally it would write logs to Stackdriver's "Global" scope, and would contain log levels. However when deployed it would write to "GAE Application", but without any levels.

Is it possible to set levels in Stackdriver while deployed to App Engine?

TasosZG
  • 1,274
  • 1
  • 6
  • 13

1 Answers1

0

When it runs in any environment that isn't App Engine Flex or Google Cloud Functions, the Winston logger logs directly to the Stackdriver Logging API. Apparently, on App Engine Flex and Google Cloud Functions it logs to stdout.

The default Stackdriver logging agent configuration for App Engine Flex will detect single-line JSON and convert it to jsonPayload. If you want finer-grained control over severity, you can configure Winston to log as single-line1 JSON and let the logging agent pick up the severity from the JSON object (see https://cloud.google.com/logging/docs/agent/configuration#process-payload).

1See How do I change my node winston JSON output to be single line

Igor Peshansky
  • 727
  • 4
  • 12