0

我目前正在尝试设置一个 csgo 赌博网站以获得乐趣,但在尝试运行 bot.js 时出现此错误

Error: Problem with log4js configuration: ({ appenders:
[ { type: 'console' },
 { type: 'file', filename: 'logs/bot_undefined.log' } ] }) - must have a property "appenders" of type object.
at tests.forEach (/var/www/html/bot/node_modules/log4js/lib/configuration.js:44:15)
at Array.forEach (native)
at Configuration.throwExceptionIf (/var/www/html/bot/node_modules/log4js/lib/configuration.js:42:11)
at new Configuration (/var/www/html/bot/node_modules/log4js/lib/configuration.js:205:10)
at Object.configure (/var/www/html/bot/node_modules/log4js/lib/log4js.js:201:12)
at Object.<anonymous> (/var/www/html/bot/bot.js:18:8)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
4

1 回答 1

0

您正在使用 v2.x 的 Log4JS 和 v0 或 v1 appender 格式。您的附加程序格式应类似于:

log4js.configure({
    appenders: {
        console: {
            type: 'console'
        },
        logstash: {
            host: '123.456.789.123',
            port: 1234,
            type: 'logstashUDP',
            logType: 'myAppType', // Optional, defaults to 'category'
            fields: {             // Optional, will be added to the 'fields' object in logstash
                field1: 'value1',
                field2: 'value2'
            },
            layout: {
                type: 'pattern',
                pattern: '%m'
            }
        }
    },
    categories: {
        default: { appenders: ['console', 'logstash'], level: 'trace' }
    }
});
于 2017-09-29T15:22:22.513 回答