目前我已经实现了express.js应用程序,并且我已经添加了log4js记录器以进行日志记录。现在我想将日志写入Redis,然后将后台工作程序写入Redis列表中,并将这些日志写入本地日志文件。
App.js看起来像这样
import { getLogger, configure } from 'log4js';
import {initServer} from './middleware/Express'
import { initRoutes } from './routes/RouterAggregator';
configure('./src/config/log4js-config.json');
const logger = getLogger("app");
const init = ()=> {
logger.info("Initializing Application");
initServer();
initRoutes();
};

日志配置文件看起来像这样。
{
"appenders": [
{
"type": "console",
"layout": {
"type": "pattern",
"pattern": "[%d] [%[%p%]] %c {%x{ln}} - %m",
"tokens": {
"ln" : "loggerFunction()"
}
}
},
{
"type": "dateFile",
"filename": "log/access.log",
"pattern": "-yyyy-MM-dd",
"alwaysIncludePattern": false,
"category": "http",
"layout": {
"type" : "pattern",
"pattern": "[%d] [%p] %c {%x{ln}} - %m",
"tokens": {
"ln" : "loggerFunction()"
}
}
},
{
"type": "dateFile",
"filename": "log/app.log",
"maxLogSize": 10485760,
"numBackups": 3,
"alwaysIncludePattern": false,
"layout": {
"type" : "pattern",
"pattern": "[%d] [%p] %c {%x{ln}} - %m",
"tokens": {
"ln" : "loggerFunction()"
}
}
},
{
"type": "logLevelFilter",
"level": "ERROR",
"appender": {
"type": "file",
"filename": "log/errors.log"
},
"layout": {
"type" : "pattern",
"pattern": "[%d] [%p] %c {%x{ln}} - %m",
"tokens": {
"ln" : "loggerFunction()"
}
}
}
]
}

我想知道如何添加redis来支持上述功能。