pinojs / pino

🌲 super fast, all natural json logger
http://getpino.io
MIT License
14.22k stars 874 forks source link

General Linux question: best command to view pino logs? #2036

Closed binarykitchen closed 1 month ago

binarykitchen commented 1 month ago

On a production Linux server, when you want to check the pino-generated logs, what command do you use and recommend?

Before I switched to pino, using a different format, this command worked:

tail -f out.log | jq

But now, not anymore, due to this error:

parse error: Unmatched '}' at line 1, column 5

Because a JSON was printed:

[19:43:16.703] ERROR (26178 on videomail.io): connect ECONNREFUSED 127.0.0.1:25
    err: {
      "type": "Error",
      "message": "connect ECONNREFUSED 127.0.0.1:25",
      "stack":
          Error: connect ECONNREFUSED 127.0.0.1:25
              at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1607:16)
      "errno": -111,
      "code": "ESOCKET",
      "syscall": "connect",
      "address": "127.0.0.1",
      "port": 25,
      "command": "CONN"
    }

So, wondering what command you guys use for that? Thanks for any advice. Cheers :)

jsumners commented 1 month ago

It looks like you are using pino-pretty to format the written logs. Don't do that.

binarykitchen commented 1 month ago

@jsumners

Right, done:

  const forHumans = isLocal();

  ....

  if (forHumans) {
    transportTargets.push(pinoPretty);
  }

:shrug:

jsumners commented 1 month ago

What should I understand from that?

Please provide a minimal reproducible example. Doing so will help us diagnose your issue. It should be the bare minimum code needed to trigger the issue, and easily runnable without any changes or extra code.

You may use a GitHub repository to host the code if it is too much to fit in a code block (or two).

binarykitchen commented 1 month ago

What should I understand from that?

It's all good. You already helped.

When you mentioned this:

It looks like you are using pino-pretty to format the written logs. Don't do that.

This made "click" in my head, and I've replied in code above: only use pinoPretty for when in local aka "human" mode :)

github-actions[bot] commented 3 weeks ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.