diff --git a/src/logger.ts b/src/logger.ts index 1d045ad9..dfb75661 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -127,7 +127,7 @@ export class Logger { // check if passed args is an object, if its not an object, add it to fields.args if (args instanceof Error) { - logEvent.fields = { ...logEvent.fields, message: args.message, stack: args.stack, name: args.name }; + logEvent.fields = { ...logEvent.fields, message: args.message, stack: args.stack, name: args.name, cause: args.cause }; } else if (typeof args === 'object' && args !== null && Object.keys(args).length > 0) { const parsedArgs = JSON.parse(JSON.stringify(args, jsonFriendlyErrorReplacer)); logEvent.fields = { ...logEvent.fields, ...parsedArgs }; @@ -353,6 +353,7 @@ function jsonFriendlyErrorReplacer(key: string, value: any) { name: value.name, message: value.message, stack: value.stack, + cause: jsonFriendlyErrorReplacer(undefined, value.cause), }; }