elastic / ecs-logging-nodejs

https://www.elastic.co/guide/en/ecs-logging/nodejs/master/intro.html
Apache License 2.0
68 stars 39 forks source link

Winston error handling is incompatible with ecs-winston-format error handling #128

Closed sveneh closed 1 year ago

sveneh commented 2 years ago

Winston allows error to be passed directly to a log message https://github.com/winstonjs/logform#errors, like winston.error(new Error()), while ecs-winston-format requires errors to be added to the ecs-specific err field, like winston.errror({ err : new Error() })

This has two side effects. The minor one is that one must refactor its own code to match the ecs guidelines. The more annoying side effect is that this will not work with Winston's special Exception https://github.com/winstonjs/winston#exceptions and Rejection https://github.com/winstonjs/winston#handling-uncaught-promise-rejections-with-winston handlers These handlers will log errors via Winston's default error handling and cannot be refactored to use the special ecs handling. As such, those errors don't show up correctly in Elasticsearch, making them harder to detect.

Please make ecs-winston-format compatible with default winston error handling.

trentm commented 1 year ago

@sveneh Thanks very much for this issue. Apologies for never having responded to it earlier. I hope to have a release out in the next week with the above fix.