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

Cannot set user defined values in those properties: logger, layer #62

Closed chungmanau closed 3 years ago

chungmanau commented 4 years ago

Hi,

I had a CF nodejs application and binds it to the application log services.

// sample code const logger = require('cf-nodejs-logging-support'); logger.error('some message');

In Kibana Application Log, I can see msg: 'some message' which is good. However some properties are hard-coded such as logger: 'nodejs-logger' and layer: '[NODEJS]'. They are pre-set in config.js.

Is there any way I can overwrite those hard-coded values, or the library exposes API to set them?

Regards, Simon

nicklas-dohrn commented 4 years ago

Hey Simon, you can override these fields with the custom field logic: log.info("test override", {"layer":"test-layer", "logger":"test-logger"});

nicklas-dohrn commented 3 years ago

The awnser provided should provide a solution to this problem, and is already supported by our library in an acceptable way. I closed this issue for this reason.

sbarzaghialteaup commented 3 years ago

Hi, Could be useful to document this, if you need I can prepare and send a PR. Regards, Sam

nicklas-dohrn commented 3 years ago

Hi Sam, I will document this in an upcoming version. I have some more changes to do in the pipeline, so I will then also add this feature. Thanks for offering your help :) Regards, Nicklas