Formatting logs

Live tail patterns

Live tail output can be formatted directly in Live tail settings as a freeform text template with columns wrapped in {column} brackets.

Example
LEVEL: {level}, PID: {context.system.pid}, THREAD: {context.runtime.thread_id}

Conditional rendering can be achieved by piping multiple values

Example
LEVEL: {level}, THREAD or PID: {context.runtime.thread_id|context.system.pid}

Colors

You can format and color your logs using a subset of ANSI codes in your log messages.

For example, this is how you could format your logs using our JavaScript client:

Log formatting example
logger.info("Logs can be \033[1mbold\033[0m, \033[31mred\033[0m, or \033[1;32mbold green\033[0m.");

Here's the result you would see in Live tail:

live-tail.png

Supported colors

Live tail supports 31-36 and 91-96 code ranges for colors in both, light and dark, themes.

Supported font styles

  • Bold: ANSI code 1
  • Light: ANSI code 2
  • Italic: ANSI code 3
  • Underline: ANSI code 4

Reset

Each font color or style needs to be reset by reset all modes (0) ANSI code. Better Stack Live tail doesn't support resetting a color or a style by starting a new one.