cf-nodejs-logging-support
cf-nodejs-logging-support copied to clipboard
Removing unnecessary logs
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" }
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
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 ?
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
outputparameter (JSON string!) and writes a new JSON string to stdout containing themsgfield only. This is not an ideal solution by far but it could temporarily mitigate the problem until the new major version is available.