I am using npm @google-cloud/logging-winston to send application log events to google stack-driver log sinks. Below is my code snippet and it works perfectly fine in my local macbook. When i try to run it inside a GCE instance (ubuntu 16.10 image compute instance on google cloud),it does not send the log events to log sinks and i am not able to see it on google cloud logging dashboard. Any help here appreciated
///// code start here
const winston = require('winston');
const Logger = winston.Logger;
const Console = winston.transports.Console;
const LoggingWinston = require('@google-cloud/logging-winston');
// Instantiates a Winston Stackdriver Logging client
const loggingWinston = LoggingWinston({
projectId: 'myproject-id',
keyFilename: 'mykey.json',
level: 'info',// log at 'warn' and above ,
labels: { "env": "poc" }
,
logName: "poc-gcl.log"
});
// Create a Winston logger that streams to Stackdriver Logging
// Logs will be written to: "projects/YOUR_PROJECT_ID/logs/winston_log"
const logger = new Logger({
level: 'info', // log at 'info' and above
transports: [
// Log to the console
new Console(),
// And log to Stackdriver Logging
loggingWinston
]
});
// Writes some log entries
logger.info('Node Winston logger initialized.Transport GCL Stakdriver logging',
{ type: "poc", server: "test" });
//code ends here.
thanks in advance - jag