# Trace Ids not added on uncaught exceptions - ecsFormat()?

**URL:** <https://discuss.elastic.co/t/trace-ids-not-added-on-uncaught-exceptions-ecsformat/305947>\
**Category:** APM\
**Tags:** nodejs\
**Created:** [May 30, 2022, 12:29pm UTC](https://discuss.elastic.co/t/trace-ids-not-added-on-uncaught-exceptions-ecsformat/305947 "2022-05-30T12:29:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexsander\_Pereira](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexsander_pereira/32/106336_2.png) [@Alexsander\_Pereira](https://discuss.elastic.co/u/Alexsander_Pereira)\
**Post date:** [May 30, 2022, 12:29pm UTC](https://discuss.elastic.co/t/trace-ids-not-added-on-uncaught-exceptions-ecsformat/305947/1 "2022-05-30T12:29:51Z")

</div>

Trace Ids not added on uncaught exceptions?

When using ECSFormat with winston I don't have TraceIds (transaction.id e etc...) information in uncaught Exceptions.  
[elastic/ecs-logging-nodejs#124](https://github.com/elastic/ecs-logging-nodejs/issues/124)

```auto
import { createLogger, format, transports } from 'winston';
import ecsFormat from '@elastic/ecs-winston-format';

const consoleOptions = {
    level: 'info',
    handleExceptions: true,
    format: ecsFormat(),
};

const consoleTransport = new transports.Console(consoleOptions);

const logger = createLogger({
    exitOnError: true,
    transports: [
        consoleTransport,
    ]
});

```

INFO:

```auto
{"@timestamp":"2022-05-27T19:10:13.556Z","log.level":"info","message":"testing info with winston logger","ecs":{"version":"1.6.0"},"event":{"dataset":"example_normal.log"},"trace":{"id":"e477cd64384c8c0f78cc00787ee622d4"},"transaction":{"id":"8c9cc366b48425c0"},"service":{"name":"example_normal","environment":"local"},"test2":"test2"}

```

UNCAUGHT EXCEPTION:

```auto
{"@timestamp":"2022-05-27T19:10:13.563Z","log.level":"error","message":"uncaughtException: a is not defined\nReferenceError: a is not defined\n at file:///home/user/code/logs-nodejs-lib/examples/example_normal.js:19:1\n at ModuleJob.run (node:internal/modules/esm/module_job:195:25)\n at async Promise.all (index 0)\n at async ESMLoader.import (node:internal/modules/esm/loader:337:24)\n at async loadESM (node:internal/process/esm_loader:88:5)\n at async handleMainPromise (node:internal/modules/run_main:61:12)","ecs":{"version":"1.6.0"},"event":{"dataset":"example_normal.log"},"trace":{},"service":{"name":"example_normal","environment":"local"},"error":{"message":"a is not defined"},"stack":"ReferenceError: a is not defined\n at file:///home/user/code/logs-nodejs-lib/examples/example_normal.js:19:1\n at ModuleJob.run (node:internal/modules/esm/module_job:195:25)\n at async Promise.all (index 0)\n at async ESMLoader.import (node:internal/modules/esm/loader:337:24)\n at async loadESM (node:internal/process/esm_loader:88:5)\n at async handleMainPromise (node:internal/modules/run_main:61:12)","exception":true,"date":"Fri May 27 2022 16:10:13 GMT-0300 (Brasilia Standard Time)","process":{"pid":359643,"uid":1000,"gid":1000,"cwd":"/home/user/code/logs-nodejs-lib/examples","execPath":"/usr/local/bin/node","version":"v16.14.0","argv":["/usr/local/bin/node","/home/user/code/logs-nodejs-lib/examples/example_normal.js"],"memoryUsage":{"rss":60342272,"heapTotal":19537920,"heapUsed":14871160,"external":2825769,"arrayBuffers":317453}},"os":{"loadavg":[1.61,1.57,1.91],"uptime":110849.91}}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 20, 2022, 8:30am UTC](https://discuss.elastic.co/t/trace-ids-not-added-on-uncaught-exceptions-ecsformat/305947/2 "2022-06-20T08:30:37Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
