Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pino pino-pretty log pattern #198

Open
JonathanTurnock opened this issue Dec 28, 2024 · 0 comments
Open

pino pino-pretty log pattern #198

JonathanTurnock opened this issue Dec 28, 2024 · 0 comments

Comments

@JonathanTurnock
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant