root@------:~# cd/home/bot
root@------:/home/bot# node site.js
/home/bot/node_modules/log4js/lib/configuration.js:43
throw new Error(Problem with log4js configuration: (${util.inspect(this.candidate, { depth: 5 })})
+
^
错误:log4js 配置问题:({ appenders: [{类型:'控制台'}, { type: 'file', filename: 'logs/site.log' } ] }) - 必须有一个对象类型的属性“appenders”。 在 tests.forEach (/home/bot/node_modules/log4js/lib/configuration.js:43:15) 在 Array.forEach( native ) 在 Configuration.throwExceptionIf (/home/bot/node_modules/log4js/lib/configuration.js:41:11) 在新配置(/home/bot/node_modules/log4js/lib/configuration.js:203:10) 在 Object.configure (/home/bot/node_modules/log4js/lib/log4js.js:205:12) 在对象。 (/home/bot/site.js:12:8) 在 Module._compile (module.js:570:32) 在 Object.Module._extensions..js (module.js:579:10) 在 Module.load (module.js:487:32) 在 tryModuleLoad (module.js:446:12)
我使用命令 npm install log4j --save
root@------:/home/bot# npm install log4j --save
错误! Linux 3.2.0-4-amd64
错误! argv “/root/.nave/installed/6.11.1/bin/node” “/root/.nave/installed/6.11.1/bin/npm” “安装” “log4j” “--保存”
错误! Node v6.11.1
错误! npm v3.10.10
错误!代码E404
npm 错误! 404 注册表在 https://registry.npmjs.org/log4j 上为 GET 返回 404 错误! 404 错误! 404 'log4j' 不在 npm 注册表中。 错误! 404 You should bug the author to publish it (or use the name yourself!) 错误! 404 错误! 404 请注意,您也可以从 错误! 404 tarball、文件夹、http url 或 git url。
npm 错误!请在任何支持请求中包含以下文件: 错误!/home/bot/npm-debug.log
最佳答案
我和你有同样的问题,使用相同的脚本xD。 我找到了解决方案!!!!!!!!!!!!! 你需要将 site.js 中的 log4js.configure 更改为此
log4js.configure({
appenders: {
out: { type: 'console' },
task: { type: 'file', filename: 'logs/site.log' }
},
categories: {
default: { appenders: [ 'out' ], level: 'info' },
task: { appenders: [ 'task' ], level: 'info' }
}
});
关于javascript - log4js npm 错误,log4js 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48527600/