question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION] Why `PinoLogger` instance don't show the error object

See original GitHub issue

When I use a PinoLogger instance to display some error object like this.logger.error(Error('foo')) I get this:

{
  "level": 50,
  "time": 1590422389076,
  "pid": 27787,
  "hostname": "--",
  "name": "app",
  "req": {
    "id": 1,
    "method": "GET",
    "url": "--",
    "headers": {
      "host": "localhost:3000",
      "user-agent": "insomnia/7.1.1",
      "accept": "*/*"
    },
    "remoteAddress": "127.0.0.1",
    "remotePort": 52126
  },
  "context": "ExceptionsHandler"
}

seems like the arg isn’t serialized by pino.stdSerializers.err because

this.logger.error( pino.stdSerializers.err(Error('foo')) )

works as expected (with { type, message, stack }). This happen even when I explicity define the serializers. Is it the right behavior?

Great lib btw!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
iamoleggacommented, May 26, 2020

Good catch, thanks. I’ll try to see what can be done here

2reactions
kirit0scommented, Sep 23, 2020

Pino expects Error object in err field and can correctly serialize it.

Example:

this.logger.error({ err: new Error('message') })
Read more comments on GitHub >

github_iconTop Results From Across the Web

Inconsistent Error logging · Issue #642 · pinojs/pino - GitHub
I've observed a few inconsistencies in logging of Error objects. ... The first output is the console output for comparison. In the second...
Read more >
A Complete Guide to Pino Logging in Node.js - Better Stack
Learn how to start logging with Pino in Node.js and go from basics to best practices in no time.
Read more >
Pino error log is empty, although error object contains ...
When using async logging (the default for the Pino logger), the process might have exited before all of the logging has been processed....
Read more >
Pino
Super fast, all natural JSON logger for Node.js.
Read more >
Multithreaded Logging with Pino - Matteo Collina - YouTube
Almost every developer thinks that adding one more log line would not decrease the performance of their server... until logging becomes the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found