sainsburys-tech / next-logger

JSON logging patcher for Next.js
MIT License
144 stars 14 forks source link

Is it possible to log to custom log files ? #20

Closed Altroo closed 1 year ago

Altroo commented 1 year ago

Hello,

As the title say i would like for example to log two files, debug.log for debug logs & error.log to catch errors, i couldn't find something related to this in the library, but perhaps i'm missing something, or override some config ?

Thank's in advance.

Altroo commented 1 year ago

Found it :

// next-logger.config.js
const pino = require('pino');
const logger = (defaultConfig) =>
    pino({
        ...defaultConfig,
        formatters: {
            level: (label) => {
                return { level: label };
            },
        },
        timestamp: pino.stdTimeFunctions.isoTime,
    }, pino.destination(`${__dirname}/logs/debug.log`));
module.exports = {
    logger,
};