a node.js module used for logging and saving application messages and events.
- logDebugBoolean - Defines if debug messages should be logged.
- logDetailBoolean - Defines if detail messages should be logged.
- logGeneralBoolean - Defines if general messages should be logged.
- logWarningBoolean - Defines if warning messages should be logged.
- logErrorBoolean - Defines if error messages should be logged.
- prefixString - Prefix each logged message with this string.
- writeLogBoolean - Defines if console messages should also be saved to disk.
- Note: If writeLog is true, all below options are required.
- fileNameString - The base name of the log files.
- filePathString - The Path that the log files should be saved to.
- fileSizeString - The maximum size for each log file. Example (100M)
- Byte = B
- KiloByte = K
- MegaByte = M
- GigaByte = G
- fileAgeInteger - The maximum number of days to write to one log file.
- fileCountInteger - The maximum number of log files to keep in rotation.
- debug(message) - green [year-month-day HH:MM:SS] DEBUG {prefix} message
- general(message) - white [year-month-day HH:MM:SS] GENERAL {prefix} message
- detail(message) - black [year-month-day HH:MM:SS] DETAIL {prefix} message
- warning(message) - yellow [year-month-day HH:MM:SS] WARNING {prefix} message
- error(message, trace?) - red [year-month-day HH:MM:SS] ERROR {prefix} message
if the message is an object, it will be stringified.
const logger = require('./Logger');
const log = new logger({
logGeneral: true,
logWarning: true,
logError: true,
writeLog: true,
prefix: 'Test App - ',
fileName: 'testLog.txt',
filePath: 'c:\\logs\\testing\\',
fileSize: '300M',
fileAge: 1,
fileCount: 5
});
log.general('Starting application...');