diff --git a/lib/application.js b/lib/application.js index cf6d78c741e..00d5e4a4c05 100644 --- a/lib/application.js +++ b/lib/application.js @@ -614,7 +614,16 @@ app.listen = function listen() { function logerror(err) { /* istanbul ignore next */ - if (this.get('env') !== 'test') console.error(err.stack || err.toString()); + if (this.get('env') !== 'test') { + console.error(err.stack || err.toString()); + + // Log the error cause chain if present + let currentCause = err.cause; + while (currentCause) { + console.error('\nCaused by:', currentCause.stack || currentCause.toString()); + currentCause = currentCause.cause; + } + } } /**