SAP / cf-nodejs-logging-support

Node.js Logging Support for Cloud Foundry provides the creation of structured log messages and the collection of request metrics
https://sap.github.io/cf-nodejs-logging-support/
Apache License 2.0
43 stars 22 forks source link

winston transport only logs one message #36

Closed sven-petersen closed 5 years ago

sven-petersen commented 5 years ago

Hi all,

we are using winston for logging in our backend application on SAP Cloud Platform - Cloud Foundry in the following Versions:

...
"cf-nodejs-logging-support": "5.2.5",
"winston": "3.2.1"
...

Based on your example for winston custom messages I have the following minimal example:

const log = require('cf-nodejs-logging-support');
const winston = require('winston');
const someTransport = log.createWinstonTransport();
const logger = winston.createLogger({
    // Bind transport to winston
    transports: [
      someTransport,
      new winston.transports.Console({
        format: winston.format.simple()
      }),
    ],
});
const intId = setInterval(() => {
  logger.warn('log me please');
}, 3000);

However the problem is, that the "cf-nodejs-logging-support"-transport will only log the very first message. After that no more messages are logged. To validate that this issue is not a general issue of winston I have added the standard console transport. The console transport works as expected and logs all messages. Output from the console:

{"component_type":"application","component_id":"-","component_name":"-","component_instance":"0","layer":"[NODEJS]","organization_id":"-","organization_name":"-","space_name":"-","space_id":"-","container_id":"-","logger":"nodejs-logger","source_instance":"0","written_at":"2019-09-12T08:29:04.569Z","written_ts":69149234026024,"level":"warn","msg":"log me please","type":"log"}
warn: log me please
warn: log me please
warn: log me please
warn: log me please

As you can see after the first messages only the warn: log me please are printed whereas the JSON-logs from this library here are missing. Somehow the logMessage-method of the transport (winston-transport.js#L12) is only called once.

jpalof commented 5 years ago

I am also interested in the response to this issue as I have hit it in my attempts to perform automated testing. Thank you

christiand93 commented 5 years ago

Thank you for your report. This problem was caused by a change in winstons transport api. We fixed our implementation in version 5.2.6.