0.0.1 • Published 6 months ago

pino-daily-rotate-file v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

pino-daily-rotate-file

NPM version

NPM

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 Variablesvalues
LOGGING_LEVELYou can mention your log level, valid values are debug, info, error, warn, fatal Default: info
LOGGING_PATHGive a path, where log file should be created. Default: current directory where process is running
MAX_LOGSMax 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
EXTENSIONThe extension of the log file generated Default: ".log"
DATE_FORMATUse '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"
UTCUse UTC time for date in filename Default: false
LOGGING_INTERVALHow often to rotate. Options are 'daily' for daily rotation, 'date' based on date_format, '1-12h' to rotate every 1-12 hours, '1-30m' to rotate every 1-30 minutes. Default: "daily"
APP_NAMEName of the log file along the date string. Eg: "YourServiceName-YYYY-MM-DD.log" Default: "File"
LOGGING_FILE_SIZEMax 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

AUTHOR: Nikhil Bharadwaj