微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

log4js中的自定义级别

如何解决log4js中的自定义级别

我正在尝试为log4js添加自定义级别。但是,我在下面看到一个错误

No overload matches this call.
Overload 1 of 2,'(filename: string): Log4js',gave the following error.
Argument of type '{ levels: { NOTICE: { value: number; colour: string; }; }; appenders: { 
out: { type: string; layout: { type: string; separator: string; }; }; aws: { type: string; 
layout: { type: string; separator: string; }; }; log: { ...; }; }; categories: { ...; }; }' 
is not assignable to parameter of type 'string'.
Overload 2 of 2,'(config: Configuration): Log4js',gave the following error.
Type '{ NOTICE: { value: number; colour: string; }; }' is not assignable to type 'Levels'.
Object literal may only specify kNown properties,and 'NOTICE' does not exist in type 
'Levels'.ts(2769)
log4js.d.ts(282,2): The expected type comes from property 'levels' which is declared here 
on type 'Configuration'

以下是我的配置:

configure({
  levels: {
    NOTICE: { value: 20001,colour: 'green' }
  },appenders: {
    out: { type: 'stdout',layout: { type: 'customLayout',separator: ' | ' } }
  },categories: {
    default: { appenders: ['out'],level: 'info' }
  }
});

我不确定我在哪里出错了,就像我按照文档所述那样实现了代码

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。