Skip to content

pino pino-pretty log pattern #198

@JonathanTurnock

Description

@JonathanTurnock

I recently spent some time figuring out how to use the pino-pretty plugin effectively. Since it wasn’t as straightforward as I initially hoped, I wanted to share my configuration and insights to help others avoid similar challenges.

Below is the setup I used, along with the key patterns and format details:

image
Field Value
Name PinoPretty
Message Pattern ^\[(\d{2}:\d{2}:\d{2}\.\d{3})\]\s+(\w+)\s+\(([^)]+)\):\s+(.*)$
Message start pattern :\s+.*
Time Format HH:MM:SS.FF3
Time capture group 1
Severity capture group 2
Category capture group 3

Pino Config

Pino Pretty Config

import pino from "pino";

const transport = pino.transport({
	targets: [
		{
			level: "warn",
			target: "pino-pretty", // must be installed separately
		},
		{
			level: "trace",
			target: "pino-pretty",
			options: {
				destination: ".logs/combined.log",
				colorize: false,
				append: false,
			},
		},
	],
});

export const rootLogger = pino(transport);

export const createLogger = (name: string) => {
	return rootLogger.child({ name });
};

Preview

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions