Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zuoez02/log4js-kafka-appender
Kafka appender for log4js
https://github.com/zuoez02/log4js-kafka-appender
Last synced: about 1 month ago
JSON representation
Kafka appender for log4js
- Host: GitHub
- URL: https://github.com/zuoez02/log4js-kafka-appender
- Owner: zuoez02
- Created: 2016-10-24T07:14:52.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-22T04:57:16.000Z (about 7 years ago)
- Last Synced: 2024-10-28T16:02:03.071Z (2 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LOG4JS KAFKA APPENDER
Kafka appender for log4js.
## Install
```bash
npm install --save log4js-Kafka-appender
```## Usage
```javascript
const log4js = require('log4js');
log4js.loadAppender('log4js-kafka-appender');
log4js.addAppender(log4js.appenders['log4js-kafka-appender']({
host: 'localhost',
port: 2181,
topic: 'topic',
level: 'INFO'
converter: (loggingEvent) => {
const data = {
data: loggingEvent.data,
level: loggingEvent.level.levelStr,
startTime: loggingEvent.startTime,
categoryName: loggingEvent.categoryName
};
return JSON.stringify(data);
}
}));
```## options
* host: zookeeper host, default localhost
* port: zookeeper port, default 2181
* topic: the topic to send, no default, must config one.
* level: send the log if level is higher than this level.
* converter: custom logging event converter for customizing your data, default as above.## Levels
The same to log4js Levels, such as ALL < TRACE < DEBUG < INFO < WARN < ERROR < FATAL < MARK < OFF
--------------------------------------
Developed by Luto