pinojs / pino

🌲 super fast, all natural json logger
http://getpino.io
MIT License
14.21k stars 875 forks source link

[question] Truncating messages #1289

Closed R0st0s closed 2 years ago

R0st0s commented 2 years ago

How should I go about limiting the length of fields logged with Pino? Let's say I have an object which has one nested field that's 100k characters long, and I want every field to be logged, but up until a specific length, for example 10k characters. I looked into transports, but they didn't really look the perfect fit. I tried to substring the fields myself with logger.info({ method: request.raw.method, route: request.raw.url, body: JSON.stringify(request.body, replacer), }); But then redaction doesn't work.

mcollina commented 2 years ago

Have you tried using the serializers: https://getpino.io/#/docs/browser?id=serialize-boolean-array?

R0st0s commented 2 years ago

Thanks for the suggestion, @mcollina! The only drawback is that the serializer are applied on the exactly matching properties, but I can work with that.

github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.