Last active
December 16, 2023 23:45
-
-
Save kuc-arc-f/7b8e817f5f90505653f2dc3928ac0737 to your computer and use it in GitHub Desktop.
log4js, setting sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const log4js = require("log4js"); | |
let dt = Date.now(); | |
let LOG_FILE_NAME = "log_" + dt; | |
console.log("dt=", dt); | |
// | |
log4js.configure({ | |
appenders: { | |
cheese: { type: "file", filename: "cheese.log" } , | |
app: { type: "file", filename: `log/${LOG_FILE_NAME}.log` } | |
}, | |
categories: { default: { appenders: ["app"], level: "DEBUG" } } | |
}); | |
const logger = log4js.getLogger("app"); | |
module.exports = logger; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const logger = require('./logger'); | |
// | |
logger.debug("Entering cheese testing"); | |
logger.error("error_123"); | |
logger.info("info_123"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment