cf-nodejs-logging-support icon indicating copy to clipboard operation
cf-nodejs-logging-support copied to clipboard

Removing unnecessary logs

Open Versiani-R opened this issue 2 years ago • 3 comments

While using log.info I get bombarded with too many properties inside the log object. Is there a way to remove such properties to have a cleaner log object ?

Problem

{"component_type":"application","component_id":"-","component_name":"-","component_instance":"0","layer":"[NODEJS]","organization_name":"-","organization_id":"-","space_name":"-","space_id":"-","container_id":"-","logger":"nodejs-logger","source_instance":"0"}

Solution ?

{ "msg": "Hello World" }

Versiani-R avatar Sep 23 '22 18:09 Versiani-R

Hi @Dr4kk0nnys,

thank you for your question. This library targets SAP Application Logging service and therefore logs several fields read from Cloud Foundry environment. Unfortunately it is not yet possible to disable/omit unwanted fields. However, we are reworking the library currently and hope to release a new version soon. This will not only allow you to add/remove specific fields, but also omit empty fields by default.

Kind regards, Christian

christiand93 avatar Sep 26 '22 11:09 christiand93

Sure thing, do you any idea when will it be available ? We're asking because we took a look at the license and we're analyzing the possibility to make changes to the code and use it meanwhile the new code/library is not available. Do you have any concerns ?

Versiani-R avatar Sep 27 '22 12:09 Versiani-R

I cannot give a clear statement on a possible release date yet. The implementation itself is done, we are currently checking compatibilities and updating our documentation for the new release.

Back to the problem:

  • Yes, you can fork and modify the code.
  • Another idea: Instead of removing fields from the log object, it would also be possible to set a custom sink function (see docs). You could define a function which reads the output parameter (JSON string!) and writes a new JSON string to stdout containing the msg field only. This is not an ideal solution by far but it could temporarily mitigate the problem until the new major version is available.

christiand93 avatar Oct 11 '22 07:10 christiand93