Log correlation with ecs-logging but in plain text

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. 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:

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

Appreciate any help.

Managed to do it this way:

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()
      ]
    });