Closed DomiiBunn closed 6 months ago
Hi @DomiiBunn,
Sorry for the long silence here! 🙏
Could you share what Pino and pino-logtail versions are you using?
Any chance you are using a level formatter with Pino? We've seen issues before when using a level formatter with multiple transports.
Thanks for reaching out!
I forgot to close this out actually.
I got it to work in the end with some tweeks. Not entreley sure what did it but ended up with
const pino = require("pino");
const { join } = require("path");
const { LOG_LEVEL, LOGTAIL_TOKEN, PWD } = process.env;
const { name, version } = require("../package.json");
const { format } = require("date-fns");
const today = format(new Date(), "yyyy-MM-dd");
const logFile = join(PWD, `/logs/${today}.log`);
const transport = pino.transport({
targets: [
{
target: "pino/file",
options: { destination: logFile },
},
...(LOGTAIL_TOKEN
? [{ target: "@logtail/pino", options: { sourceToken: LOGTAIL_TOKEN } }]
: []),
{ target: "pino-pretty" },
],
});
const logger = pino(
{
name,
level: LOG_LEVEL || "info",
version,
},
transport
);
module.exports = logger;
I'm glad you got it working in the end.
Thank you for sharing the code!
Hello everyone,
I've encountered an issue while attempting to utilize both
pino-pretty
and@logtail/pino
transports with the Pino logger in my Node.js application. The problem arises when configuring multiple transports – only the logs sent topino-pretty
are displayed, while nothing is logged to the standard output (stdout).Steps to Reproduce:
pino-pretty
and@logtail/pino
.Expected Behavior: I expect the logger to log messages both to
pino-pretty
and logtail for enhanced readabilityActual Behavior: Only logs sent to
pino-pretty
are visible, while nothing is logged to logtail.Code Snippets:
Working code (but missing stdout logging):
Not logging to stdout, logging to pino-pretty:
Additional Information: I'm unsure whether this issue is due to a bug in the configuration or if I'm missing something in my setup. Any assistance or guidance on resolving this issue would be greatly appreciated. Thank you!