1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| import path from "node:path"; import log4js from "log4js";
log4js.configure({ appenders: { out: { type: "stdout" }, dateFile: { type: "dateFile", filename: path.resolve(import.meta.dirname, "../", "logs", "dateFile", "log"), pattern: "yyyy-MM-dd_hh-mm-ss.log", alwaysIncludePattern: true, fileNameSep: '.', encoding: "utf-8", maxLogSize: "10M", numBackups: 3, mode: 0o666, layout: { type: "basic", }, }, file: { type: "file", filename: path.resolve(import.meta.dirname, "../", "logs", "file", "log.log"), maxLogSize: "10M", backups: 5, fileNameSep: ".", encoding: "utf-8", mode: 0o666, keepFileExt: true, layout: { type: "basic", }, }, fileSync: { type: "fileSync", filename: path.resolve(import.meta.dirname, "../", "logs", "fileSync", "log.log"), maxLogSize: "10M", backups: 5, encoding: "utf-8", mode: 0o666, layout: { type: "basic", }, }, }, categories: { default: { appenders: ["out"], level: "all" }, dateFile: { appenders: ["dateFile"], level: "all" }, file: { appenders: ["file"], level: "all" }, fileSync: { appenders: ["fileSync"], level: "all" }, }, });
export const logger = log4js.getLogger("default"); export const loggerDateFile = log4js.getLogger("dateFile"); export const loggerFile = log4js.getLogger("file"); export const loggerFileSync = log4js.getLogger("fileSync");
|