I cannot make winston logger to write logs to stackdriver console. I deploy my functions as google firebase functions (using firebase deploy
). console
logging works fine, but we don't use such tool in the project.
What I tried:
- output to stderr using https://github.com/greglearns/winston-stderr
- using https://www.npmjs.com/package/@google-cloud/logging-winston (both
winston.add(require('@google-cloud/logging-winston')); winston.log('error', 'Winston error!');
and also adding with parameters such as project IDprojectId
/ service account JSON credentials filekeyFilename
); - using https://github.com/findanyemail/winston-transport-stackdriver-error-reporting . Also no luck. I still cannot see logs in stackdriver.
Please suggest... I'm tired of experiments (each re-deploy takes time)
Winston's default Console transport fails because it uses
console._stdout.write
when it's available, which is not accepted by Firebase Functions.There's now a Google Cloud transport package for Stackdriver you can try. Haven't used it and it requires node
^8.11.2
if you're using Winston 3.Finally what I did - implemented custom transport which actually calls
console.log
under the hood. This helped.