# Log correlation with ecs-logging but in plain text

**URL:** <https://discuss.elastic.co/t/log-correlation-with-ecs-logging-but-in-plain-text/355335>\
**Category:** Elastic Observability\
**Created:** [March 13, 2024, 5:49pm UTC](https://discuss.elastic.co/t/log-correlation-with-ecs-logging-but-in-plain-text/355335 "2024-03-13T17:49:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![missael.denadai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/missael.denadai/32/118538_2.png) [@missael.denadai](https://discuss.elastic.co/u/missael.denadai)\
**Post date:** [March 13, 2024, 5:49pm UTC](https://discuss.elastic.co/t/log-correlation-with-ecs-logging-but-in-plain-text/355335/1 "2024-03-13T17:49:00Z")

</div>

Hi,

I've managed to instrument our Next.js application with the APM agent for Node.js, including log correlation using [ecs-logging and Winston](https://www.elastic.co/guide/en/ecs-logging/nodejs/master/winston.html). However, I can't figure how to inject the corelation fields (trace, span and transaction ids) also when using a custom format. Our log configuration is not suited for JSON logs yet, so I would like to log something like this:

```auto
{timestamp} {level} {trace_id} {span_id} {transaction_id} - {message}

```

Appreciate any help.

---

<div class="post-metadata">

**Author:** ![missael.denadai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/missael.denadai/32/118538_2.png) [@missael.denadai](https://discuss.elastic.co/u/missael.denadai)\
**Post date:** [March 13, 2024, 11:12pm UTC](https://discuss.elastic.co/t/log-correlation-with-ecs-logging-but-in-plain-text/355335/2 "2024-03-13T23:12:38Z")

</div>

Managed to do it this way:

```auto
const logger =
    winston.createLogger({
      format: winston.format.combine(
          ecsFields(/* options */),
          winston.format.timestamp(),
          format.printf((info) => {
            return `${info.timestamp} ${info.level} traceId=${info['trace.id']} transactionId=${info['transaction.id']} ${info.message}`;
          })
      ),
      transports: [
        new winston.transports.Console()
      ]
    });

```
