Nodejs log4js uses PM2 to start not logging

the log is normal in local mode. After starting with pm2 cluster mode, the log cannot be output. The method of searching on the Internet has been tried all over, but it still doesn"t work.

version:
nodejs:9.0.0
express:4.11
log4js:2.5.3

log configuration file:


log4js.configure(
  {
    pm2: true,
    pm2InstanceVar: "INSTANCE_ID",  
    //pm2InstanceVar: 0, 
    replaceConsole: true,
    appenders: {
        stdout: {
            type: "stdout"
        },
        req: {
            type: "dateFile",
            filename: "logs/",
            pattern: "yyyy-MM-dd.log",
            alwaysIncludePattern: true
        }
    },
    categories: {
        default: { appenders: ["stdout", "req"], level: "debug" }
    }
}


);
 
var logger = log4js.getLogger("H5API");
Mar.28,2021

are you sure it's not related to the output level


finally solved the problem?

Menu