0

所以我试图添加一个多日志文件日志系统,但我面临一些由于控制台自动关闭而无法读取的错误......

    log4js.configure({
        appenders: { 
            logs: { type: ['file','console'], filename: path.join(__dirname, 'logs/bot_logs.log') },
            exceptions: {  type: 'file', filename: path.join(__dirname, 'logs/bot_exceptions.log') },
            warnings: {  type: 'file', filename: path.join(__dirname, 'logs/bot_warnings.log') },
            rejections: {  type: 'file', filename: path.join(__dirname, 'logs/bot_rejections.log') }        
  },
        categories: { 
             default: { appenders: ['logs'], level: 'debug' },
             'exception': { appenders: ['exceptions'], level: 'error' },
             'warning': { appenders: ['warnings'], level: 'warning' },  
             'rejection':  { appenders: ['rejections'], level: 'fatal' }
        }
    });

    const logger = log4js.getLogger('logs');
    const excep = log4js.getLogger('exception');  
    const warni = log4js.getLogger('warning');
    const rejec = log4js.getLogger('rejection');
    logger.log(....); excep.error(.....); warni.warn(....); rejec.fatal(....);

截屏

4

0 回答 0