Closed cklat closed 2 weeks ago
I think it should be fine, just change the initialisation from const _logger = require('pino-http')();
to something like:
const fs = require('fs');
const _logger = require('pino-http')({
level: 'trace',
},
pino.multistream([
{ stream: process.stdout }, // Log to stdout with pretty printing
{ stream: fs.createWriteStream('your_log_file.log') }, // Log to file
]));
Let me know if it works as I have not tried it myself :)
Thanks for the fast reply! :)
edit// forget everything I may have written. The fault was on my side. It works! :)
Hi @tomups
I'm glad that I came across your tutorial on how to log the request and response in Nextjs in an easy way, although a bit hackish, as every more sophisticated logging solution for NextJS seems to be...
Following your guide, I'm wondering if it is possible to have a multistream logging, i.e. logging to several destinations. I'd like to log to stdout as well to a predefined file path.
I know with the server-side pino package you can achieve this by passing a multistream object like so:
but I'm not sure if this is gonna work or recommended to modify the next node module so much.
Any thoughts on this?