gpt4 book ai didi

Node.js - Winston-loggly 模块抛出 "Cannot read property ' length' of undefined”错误

转载 作者:太空宇宙 更新时间:2023-11-03 23:29:30 25 4
gpt4 key购买 nike

我正在尝试在我的 Sails.js 应用程序中设置 Winston Loggly。我关注了Sails.js - Using A Custom Logger文档并设置我的 /config/log.js 文件,如下所示:

// Send logs to Loggly using Winston
var winston = require('winston');
require('winston-loggly');

var customLogger = new winston.Logger();
customLogger.add(winston.transports.Loggly, {
inputToken: MY INPUT TOKEN,
auth: {
username: MY USERNAME,
password: MY PASSWORD
},
subdomain: MY SUBDOMAIN,
level: 'info',
tags: ['web-service', process.env.NODE_ENV],
json: true
});

module.exports.log = {

level: 'info',
custom: customLogger,

// Disable captain's log so it doesn't prefix or stringify our meta data.
inspect: false

};

无论我做什么,我都会在控制台中收到以下错误:

/Users/Nag/Code/web-service/node_modules/winston-loggly/node_modules/loggly/lib/loggly/client.js:190
return isSolid.test(tag) && tag.length <= 64;
^

TypeError: Cannot read property 'length' of undefined
at /Users/Nag/Code/web-service/node_modules/winston-loggly/node_modules/loggly/lib/loggly/client.js:190:36
at Array.filter (native)
at Loggly.tagFilter (/Users/Nag/Code/web-service/node_modules/winston-loggly/node_modules/loggly/lib/loggly/client.js:186:15)
at new exports.Loggly (/Users/Nag/Code/web-service/node_modules/winston-loggly/node_modules/loggly/lib/loggly/client.js:62:12)
at Object.exports.createClient (/Users/Nag/Code/web-service/node_modules/winston-loggly/node_modules/loggly/lib/loggly/client.js:30:10)
at new exports.Loggly (/Users/Nag/Code/web-service/node_modules/winston-loggly/lib/winston-loggly.js:50:24)
at Logger.add (/Users/Nag/Code/web-service/node_modules/winston/lib/winston/logger.js:475:41)
at Object.<anonymous> (/Users/Nag/Code/web-service/config/log.js:18:14)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
at /usr/local/lib/node_modules/sails/node_modules/include-all/index.js:129:29
at Array.forEach (native)
at requireAll (/usr/local/lib/node_modules/sails/node_modules/include-all/index.js:44:9)
at buildDictionary (/usr/local/lib/node_modules/sails/node_modules/sails-build-dictionary/index.js:68:14)
at Function.module.exports.aggregate (/usr/local/lib/node_modules/sails/node_modules/sails-build-dictionary/index.js:190:9)
at Array.loadOtherConfigFiles (/usr/local/lib/node_modules/sails/lib/hooks/moduleloader/index.js:239:27)
at /usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:591:38
at _arrayEach (/usr/local/lib/node_modules/sails/node_modules/async/lib/async.js:85:13)

我似乎无法解决这个问题。我该如何修复它?

最佳答案

该错误似乎表明,由于某种原因,您的 process.env.NODE_ENV 为 null、空或未定义。你能检查一下吗?

关于Node.js - Winston-loggly 模块抛出 "Cannot read property ' length' of undefined”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39900899/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com