pinojs / pino

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

Transport With PM2 will delay logging #1454

Closed HsinHeng closed 2 years ago

HsinHeng commented 2 years ago

We use pino.destination({ sync: false }) with PM2 to run node.js before, and logging seem to work fine.

Recently, We upgrade pino to v7 and use transport with PM2. After process run a moment, some logs will delay output N minutes to PM2 stdout & file. It's difficult to reproduce.

Does Pino tansport compatible with PM2?

The version of pino is used.

"pino": "^7.10.0",
const logger = pino({
        base: false,
        timestamp: pino.stdTimeFunctions.isoTime,
        level: "info",
        formatters: {
            level: (label) => {
                return { level: label };
            },
        },
        transport: {
            target: "pino/file",
        }
});

PM2

module.exports = {
        "apps" : [
                {
                        "name": "app",
                        "script": "./bin/app.js",
                        "instances": 1,
                        "exec_mode": "fork",
                        "merge_logs": true,
                        "autorestart" : false,
                        "env": {
                                "NODE_ENV": "production",
                        },
                        "node_args": [
                                "--max_old_space_size=1024"
                        ]
                },
    ]
};
mcollina commented 2 years ago

I would not recommend anybody to use pm2 embedded logging functionality. PM2 heavily monkeypatches Node.js and the transport system is likely missing those bits. Your best bet is to pass process.stdout explicitly or nothing.

I'm sorry we couldn't help but we are not users of PM2.

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.