Skip to content

Missing a parenthesis at ECS node.js logging #3027

@liu-xiao-guo

Description

@liu-xiao-guo

At the link https://www.elastic.co/guide/en/ecs-logging/nodejs/current/pino.html#pino-ref, there is a missing "(" in the code:

image

The correct code should be:

const http = require('http');
const { ecsFormat } = require('@elastic/ecs-pino-format');
const pino = require('pino');

const log = pino(ecsFormat({ convertReqRes: true })); 

const server = http.createServer(function handler (req, res) {
  res.setHeader('Foo', 'Bar');
  res.end('ok');
  log.info({ req, res }, 'handled request'); 
});

server.listen(3000, () => {
  log.info('listening at http://localhost:3000');
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions