-1

我应该如何改变这个:

log4js.configure({
    appenders: [
        { type: 'console' },
        { type: 'file', filename: 'logs/site.log' }
    ]
});

因为我得到这个错误:

Error: Problem with log4js configuration: ({ appenders:
   [ { type: 'console' },
     { type: 'file', filename: 'logs/site.log' } ] }) - must have a property "appenders" of type object.
4

1 回答 1

0

appenders应该是一个普通对象,提供每个附加程序作为给定名称(键)的值:

log4js.configure({
    appenders: {
        con: { type: 'console' },
        fil: { type: 'file', filename: 'logs/site.log' }
    }
});

然后按名称引用附加程序,如下所示:

log4js.getLogger('con');

另请参阅文档

于 2017-07-26T21:54:21.430 回答