You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
886 B
38 lines
886 B
import path from "node:path";
|
|
import log4js from "log4js";
|
|
import fs from "node:fs";
|
|
|
|
const logDir = path.resolve(process.cwd(), "logs");
|
|
const pathLog = path.resolve(logDir, "running.log");
|
|
|
|
if (!fs.existsSync(logDir)) {
|
|
fs.mkdirSync(logDir, { recursive: true });
|
|
}
|
|
|
|
const configureLogger = () => {
|
|
const log4jsConfig = function () {
|
|
return {
|
|
appenders: {
|
|
file: {
|
|
type: "file",
|
|
filename: pathLog,
|
|
},
|
|
console: {
|
|
type: "console",
|
|
},
|
|
},
|
|
categories: {
|
|
default: {
|
|
appenders: ["file", "console"],
|
|
level: "all",
|
|
}
|
|
},
|
|
};
|
|
};
|
|
|
|
log4js.configure(log4jsConfig());
|
|
|
|
return log4js;
|
|
}
|
|
|
|
export default configureLogger();
|