javascriptnode.jspapertrail-app

Papertrail color logging


I've found on the internet that Papertrail lets you log using ANSI colors.

That's a great deal for me because I have lots of logs on my node.js app and adding more color helps me to understand what's going on when there's a lot of people hitting the service.

So I read a little about ANSI escape code for colors and I managed to write this on my terminal (which works alright)

printf \\x1b[31mHello\\n\\x1b[0m

Unfortunately when I try the same thing on my node.js app the output in papertrail is not what I'm looking for:

papertrail screen

My code in the node.js app is this:

logger.debug('\x1b[31mGET /app/config\x1b[0m');

UPDATE: Since I'm using nlogger maybe I can use its color feature. However, I would like your opinion about this :-)


Solution

  • I ended up using the following since I was already using nlogger:

    logger.trace("SOMETHING HERE")
    logger.info("SOMETHING HERE IN ANOTHER COLOR")