pino-daily-rotate-file
v0.0.1
Published
Pino Daily Log Rotate File
Downloads
309
Maintainers
Readme
pino-daily-rotate-file
A daily log rotating pino package which logs to a rotating file. Logs can be rotated based on a size limit, date and old logs can be removed based on count or elapsed days.
Install
npm install pino-daily-rotate-file
- Ready to use pino rotating file logger. Just install and use.
Options
You can provide the below keys in as your environment variables,
- If any env variable is not provided, their default values are used.
| Environment Variables | values | | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | LOGGING_LEVEL | You can mention your log level, valid values are debug, info, error, warn, fatal Default: info | | LOGGING_PATH | Give a path, where log file should be created. Default: current directory where process is running | | MAX_LOGS | Max number of logs to keep. If not set, it won't remove past logs. It uses its own log audit file to keep track of the log files in a json format. It won't delete any file not contained in it. It can be a number of files or number of days. If using days, add 'd' as the suffix. e.g., '10d' for 10 days. If no value is provide, old log file won't be deleted | | EXTENSION | The extension of the log file generated Default: ".log" | | DATE_FORMAT | Use 'Y' for full year, 'M' for month, 'D' for day, 'H' for hour, 'm' for minutes, 's' for seconds . If using 'date' frequency, it is used to trigger file change when the string representation changes. It will be used to replace %DATE% in the filename. All replacements are numeric only. Default: "YYYY-MM_DD" | | UTC | Use UTC time for date in filename Default: false | | LOGGING_INTERVAL | How often to rotate. Options are 'daily' for daily rotation, 'date' based on date_format, '[1-12]h' to rotate every 1-12 hours, '[1-30]m' to rotate every 1-30 minutes. Default: "daily" | | APP_NAME | Name of the log file along the date string. Eg: "YourServiceName-YYYY-MM-DD.log" Default: "File" | | LOGGING_FILE_SIZE | Max size of the file after which it will rotate. It can be combined with frequency or date format. The size units are 'k', 'm' and 'g'. Units need to directly follow a number e.g. 1g, 100m, 20k. Default: '1g' |
Usage
var logger = require("pino-daily-rotate-file");
logger.info("Hello World!");
ES6
import logger from "pino-daily-rotate-file";
logger.info("Hello World!");
LICENSE
MIT