启动npm时log4js附加程序出现调试错误

时间:2019-05-03 05:29:36

标签: node.js npm log4js-node

启动npm时遇到错误。该错误指出“错误:{类型:'log4js-syslog-appender'的log4js配置问题”,从本质上看,log4js配置的格式可能不正确。我是Node的新手,希望能对下一步的建议有所帮助。

我继承了用Node 4.2和npm 3.x编写的一堆代码,我不得不编译openssl fips二进制文件,然后重新编译并重新安装node(6.11.1)和npm(3.10.10)。我现在只是想尝试启动npm并遇到错误。

Config.js在log4js部分看起来像这样:


/*
|--------------------------------------------------
| Logging
|--------------------------------------------------
*/

var log4js = require('log4js');
var use_syslog = process.env.LOG_SYSLOG == "true";
var appenders = [ { type: 'console' } ];
if (use_syslog) {
    appenders.push({ type: 'log4js-syslog-appender',
                     tag: 'API',
                     facility: 'local0',
                     path: '/dev/log',
                     transport: 'socket' });
}
log4js.configure({
    appenders: appenders
});
config.logger = use_syslog ? log4js.getLogger('syslog') : log4js.getLogger('console') ;
config.logger.setLevel(process.env.DEBUG_LEVEL);

我想找到一种解决此错误的方法,但无法弄清楚我需要在config.js文件中进行什么确切的更改。如果可以提供任何指导,那就太好了。

确切的错误如下:

================================================ =========================

oi@oi01:~/api$ npm start

> oi-api@2.0.0 start /home/oi/api
> babel-node server.js --presets es2015

/home/oi/api/node_modules/log4js/lib/log4js.js:316
      throw new Error(
      ^

Error: Problem reading log4js config { appenders: 
   [ { type: 'console', makers: [Object] },
     { type: 'log4js-syslog-appender',
       tag: 'API',
       facility: 'local0',
       path: '/dev/log',
       transport: 'socket',
       makers: [Object] } ] }. Error was "log4js configuration problem for { type: 'log4js-syslog-appender',
  tag: 'API',
  facility: 'local0',
  path: '/dev/log',
  transport: 'socket',
  makers: 
   { console: [Function: bound configure],
     'log4js-syslog-appender': [Function: bound configure] } }" (Error: log4js configuration problem for { type: 'log4js-syslog-appender',
  tag: 'API',
  facility: 'local0',
  path: '/dev/log',
  transport: 'socket',
  makers: 
   { console: [Function: bound configure],
     'log4js-syslog-appender': [Function: bound configure] } }
    at /home/oi/api/node_modules/log4js/lib/log4js.js:256:15
    at Array.forEach (native)
    at configureAppenders (/home/oi/api/node_modules/log4js/lib/log4js.js:248:18)
    at configureOnceOff (/home/oi/api/node_modules/log4js/lib/log4js.js:308:7)
    at Object.configure (/home/oi/api/node_modules/log4js/lib/log4js.js:371:3)
    at Object.<anonymous> (/home/oi/api/config/config.js:92:8)
    at Module._compile (module.js:570:32)
    at loader (/home/oi/api/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/home/oi/api/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:487:32))
    at configureOnceOff (/home/oi/api/node_modules/log4js/lib/log4js.js:316:13)
    at Object.configure (/home/oi/api/node_modules/log4js/lib/log4js.js:371:3)
    at Object.<anonymous> (/home/oi/api/config/config.js:92:8)
    at Module._compile (module.js:570:32)
    at loader (/home/oi/api/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/home/oi/api/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)

npm ERR! Linux 4.4.0-1002-fips
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.11.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! oi-api@2.0.0 start: `babel-node server.js --presets es2015`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the oi-api@2.0.0 start script 'babel-node server.js --presets es2015'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the oi-api package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     babel-node server.js --presets es2015
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs oi-api
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls oi-api
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/oi/api/npm-debug.log

================================================ ================

0 个答案:

没有答案