Installations
npm install @xeefour/winston-elastic
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
20.10.0
NPM Version
10.2.3
Releases
Unable to fetch releases
Total Downloads
Cumulative downloads
Total Downloads
424
Last day
0%
2
Compared to previous day
Last week
433.3%
16
Compared to previous week
Last month
675%
31
Compared to previous month
Last year
0%
424
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Module Documentation: @xeefour/winston-elastic
Description
The @xeefour/winston-elastic
module provides a customizable logger using the Winston library. This logger supports writing logs to daily rotated files and displaying them in the console. It also formats logs according to the Elastic Common Schema (ECS).
Installation
Ensure that you have Node.js installed. Then, install the required dependencies:
1npm install @xeefour/winston-elastic
Usage
- Import the
@xeefour/winston-elastic
function from this module. - Call the function with the desired configuration options.
- Use the returned logger to log messages.
Example
1const winstonLogger = require("@xeefour/winston-elastic"); 2 3// Create a logger with custom options 4const logger = winstonLogger(); 5 6// Or add option 7const logger = winstonLogger({ 8 datePattern: "YYYY-MM-DD-HH", 9 maxSize: "20m", 10 maxFiles: "14d", 11 zippedArchive: true, 12 appName: "app", 13 level: "info", 14 displayLog: true, 15 dirname: "logs", 16}); 17// Log an example message 18logger.info("Hello, world!"); 19 20// Other log levels: logger.error(), logger.warn(), logger.debug(), etc.
Configuration Options
datePattern
: The pattern for daily rotated log files (default:"YYYY-MM-DD-HH"
).maxSize
: Maximum size of each log file (default:"20m"
).maxFiles
: Maximum number of log files to keep (default:"14d"
).zippedArchive
: Whether to compress old log files (default:true
).appName
: The name of your application (used as a label in logs default: null).level
: The minimum log level to display (default:"info"
).displayLog
: Whether to display logs in the console (default:true
).dirname
: The directory where log files will be stored (added option).
Log Format
Logs are formatted according to ECS. Each log entry includes a timestamp, log level, and message.
License
This module is released under the MIT License.
No vulnerabilities found.
No security vulnerabilities found.