How to log to GKE StackDriver using winston logger?

12/19/2018

I'm following this instructions to add winston logger to my node backend app.

It is currently running on GKE and normal console.log does show up in stackdriver.
Though, using winston logger doesn't display the logs.

I have just set up the logger like this:

export const logger = winston.createLogger({
  level,
  format: winston.format.simple(),
  transports: [
    new winston.transports.Console({
      handleExceptions: true,
    }),
    new LoggingWinston(),
  ],
  exitOnError: false,
});

I don't need it to log from my local machine, is there anything else I need to configure?

-- itaied
google-cloud-platform
google-kubernetes-engine
node.js
winston

1 Answer

12/22/2018

It seems that in the following code you've provided, you did not add the following lines such as:

(logger.error), (logger.info).

These would essential to write the log entries which @JohnHanley had mentioned earlier. Notice that in the doc that you mentioned, those two lines were also included.

-- hachemon
Source: StackOverflow