我在试着做量角器测试。但是面对log4js的问题。我做了npm安装log4js。启动前的配置看起来正确吗?对于当前版本的log4js,有什么需要更改的格式吗?
以下是错误:
Error: Problem with log4js configuration: ({
appenders: {
out: {
type: 'log4js-protractor-appender',
category: 'protractorLog4js'
},
app: {
type: 'file',
filename: './logs/ExecutionLog.log',
category: 'protractorLog4js'
}
},
categories: { default: { appenders: [ 'out', 'app' ], level: 'info' } }
}) - appender "out" is not valid (type "log4js-protractor-appender" could not be found)
at C:\Project\PrjectName\node_modules\log4js\lib\configuration.js:31:13
at Array.forEach (<anonymous>)
at Object.throwExceptionIf (C:\Project\PrjectName\node_modules\log4js\lib\configuration.js:29:9)
at createAppender (C:\Project\PrjectName\node_modules\log4js\lib\appenders\index.js:47:17)
at C:\Project\PrjectName\node_modules\log4js\lib\appenders\index.js:77:25
at Array.forEach (<anonymous>)
at setup (C:\Project\PrjectName\node_modules\log4js\lib\appenders\index.js:75:33)
at C:\Project\PrjectName\node_modules\log4js\lib\configuration.js:46:33
at Array.forEach (<anonymous>)
at Object.configure (C:\Project\PrjectName\node_modules\log4js\lib\configuration.js:46:13)
npm ERR! Test failed. See above for more details.
这是我在配置文件中的启动前配置。
beforeLaunch:function(){
log4js.configure({
appenders: {
out:{ type: 'log4js-protractor-appender'},
app:{ type: "file",
filename: './logs/ExecutionLog.log'}
},
categories: {
default: { appenders: [ 'out', 'app' ], level: 'info' }
}
});
},
谢谢
发布于 2020-04-21 22:08:27
log4js支持的追加程序类型为:
export type Appender = CategoryFilterAppender
| ConsoleAppender
| FileAppender
| SyncfileAppender
| DateFileAppender
| LogLevelFilterAppender
| NoLogFilterAppender
| MultiFileAppender
| MultiprocessAppender
| RecordingAppender
| StandardErrorAppender
| StandardOutputAppender
| CustomAppender;
如果从名称中删除"appender“,您将得到受支持的ex类型:控制台、文件、多文件.等
下面是一个简单的配置。
const log4js_config: Configuration = {
appenders: {
consoleErrors: {
type: 'logLevelFilter',
appender: 'console',
level: 'error'
},
console: {
type: 'console'
},
},
categories: {
default: { appenders: [ 'console', 'consoleErrors' ], level: 'debug' }
}
};
const Log4js = require('log4js');
log4js.configure(LOG4JS_CONFIGURATION);
就像这样,默认类别中有两种类型的追加器。
无论level.
。
您可以在: log4js中阅读有关https://github.com/log4js-node/log4js-node配置的更多信息。
示例添加程序如何工作以及如何配置它们:https://github.com/log4js-node/log4js-node/tree/master/examples
https://stackoverflow.com/questions/61351127
复制相似问题