Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logging to stackdriver from winston

I am using the library here to log to Stackdriver from Node.js. However, the logs aren't showing up - I think because I'm not specifying a metadata resource, such as 'global'. How do I do that?

var winston = require('winston');
var transport = require('@google-cloud/logging-winston');

winston.add(transport, {
  projectId: 'myproject',
  keyFilename: 'google_key.json',
  level: 'warn' // log at 'warn' and above 
});

winston.error('warp nacelles offline');
like image 798
skunkwerk Avatar asked May 31 '26 07:05

skunkwerk


1 Answers

The solution is to add a 'label' field to the configuration, like so:

winston.add(transport, {
  projectId: 'myproject',
  keyFilename: 'google_key.json',
  level: 'warn', // log at 'warn' and above,
  label: 'Global'
});
like image 81
skunkwerk Avatar answered Jun 03 '26 00:06

skunkwerk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!