docs: adding mention of InfluxDB appender

This commit is contained in:
rnd-debug 2020-05-19 06:04:46 +02:00
parent 5175f3f2fc
commit 8d2f69c336
2 changed files with 60 additions and 47 deletions

View File

@ -1,6 +1,5 @@
# log4js-node [![Build Status](https://secure.travis-ci.org/log4js-node/log4js-node.png?branch=master)](http://travis-ci.org/log4js-node/log4js-node) [![codecov](https://codecov.io/gh/log4js-node/log4js-node/branch/master/graph/badge.svg)](https://codecov.io/gh/log4js-node/log4js-node)
[![NPM](https://nodei.co/npm/log4js.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/log4js/)
This is a conversion of the [log4js](https://github.com/stritti/log4js)
@ -14,26 +13,28 @@ There have been a few changes between log4js 1.x and 2.x (and 0.x too). You shou
Out of the box it supports the following features:
* coloured console logging to stdout or stderr
* file appender, with configurable log rolling based on file size or date
* a logger for connect/express servers
* configurable log message layout/patterns
* different log levels for different log categories (make some parts of your app log as DEBUG, others only ERRORS, etc.)
- coloured console logging to stdout or stderr
- file appender, with configurable log rolling based on file size or date
- a logger for connect/express servers
- configurable log message layout/patterns
- different log levels for different log categories (make some parts of your app log as DEBUG, others only ERRORS, etc.)
Optional appenders are available:
* [SMTP](https://github.com/log4js-node/smtp)
* [GELF](https://github.com/log4js-node/gelf)
* [Loggly](https://github.com/log4js-node/loggly)
* Logstash ([UDP](https://github.com/log4js-node/logstashUDP) and [HTTP](https://github.com/log4js-node/logstashHTTP))
* logFaces ([UDP](https://github.com/log4js-node/logFaces-UDP) and [HTTP](https://github.com/log4js-node/logFaces-HTTP))
* [RabbitMQ](https://github.com/log4js-node/rabbitmq)
* [Redis](https://github.com/log4js-node/redis)
* [Hipchat](https://github.com/log4js-node/hipchat)
* [Slack](https://github.com/log4js-node/slack)
* [mailgun](https://github.com/log4js-node/mailgun)
- [SMTP](https://github.com/log4js-node/smtp)
- [GELF](https://github.com/log4js-node/gelf)
- [Loggly](https://github.com/log4js-node/loggly)
- Logstash ([UDP](https://github.com/log4js-node/logstashUDP) and [HTTP](https://github.com/log4js-node/logstashHTTP))
- logFaces ([UDP](https://github.com/log4js-node/logFaces-UDP) and [HTTP](https://github.com/log4js-node/logFaces-HTTP))
- [RabbitMQ](https://github.com/log4js-node/rabbitmq)
- [Redis](https://github.com/log4js-node/redis)
- [Hipchat](https://github.com/log4js-node/hipchat)
- [Slack](https://github.com/log4js-node/slack)
- [mailgun](https://github.com/log4js-node/mailgun)
- [InfluxDB](https://github.com/rnd-debug/log4js-influxdb-appender)
## Getting help
Having problems? Jump on the [slack](https://join.slack.com/t/log4js-node/shared_invite/enQtODkzMDQ3MzExMDczLWUzZmY0MmI0YWI1ZjFhODY0YjI0YmU1N2U5ZTRkOTYyYzg3MjY5NWI4M2FjZThjYjdiOGM0NjU2NzBmYTJjOGI) channel, or create an issue. If you want to help out with the development, the slack channel is a good place to go as well.
## installation
@ -45,33 +46,40 @@ npm install log4js
## usage
Minimalist version:
```javascript
var log4js = require('log4js');
var log4js = require("log4js");
var logger = log4js.getLogger();
logger.level = 'debug';
logger.level = "debug";
logger.debug("Some debug messages");
```
By default, log4js will not output any logs (so that it can safely be used in libraries). The `level` for the `default` category is set to `OFF`. To enable logs, set the level (as in the example). This will then output to stdout with the coloured layout (thanks to [masylum](http://github.com/masylum)), so for the above you would see:
```bash
[2010-01-17 11:43:37.987] [DEBUG] [default] - Some debug messages
```
See example.js for a full example, but here's a snippet (also in `examples/fromreadme.js`):
```javascript
const log4js = require('log4js');
const log4js = require("log4js");
log4js.configure({
appenders: { cheese: { type: 'file', filename: 'cheese.log' } },
categories: { default: { appenders: ['cheese'], level: 'error' } }
appenders: { cheese: { type: "file", filename: "cheese.log" } },
categories: { default: { appenders: ["cheese"], level: "error" } }
});
const logger = log4js.getLogger('cheese');
logger.trace('Entering cheese testing');
logger.debug('Got cheese.');
logger.info('Cheese is Comté.');
logger.warn('Cheese is quite smelly.');
logger.error('Cheese is too ripe!');
logger.fatal('Cheese was breeding ground for listeria.');
const logger = log4js.getLogger("cheese");
logger.trace("Entering cheese testing");
logger.debug("Got cheese.");
logger.info("Cheese is Comté.");
logger.warn("Cheese is quite smelly.");
logger.error("Cheese is too ripe!");
logger.fatal("Cheese was breeding ground for listeria.");
```
Output (in `cheese.log`):
```bash
[2010-01-17 11:43:37.987] [ERROR] cheese - Cheese is too ripe!
[2010-01-17 11:43:37.990] [FATAL] cheese - Cheese was breeding ground for listeria.
@ -82,21 +90,23 @@ Output (in `cheese.log`):
If you're writing a library and would like to include support for log4js, without introducing a dependency headache for your users, take a look at [log4js-api](https://github.com/log4js-node/log4js-api).
## Documentation
Available [here](https://log4js-node.github.io/log4js-node/).
There's also [an example application](https://github.com/log4js-node/log4js-example).
## TypeScript
```ts
import { configure, getLogger } from 'log4js';
configure('./filename');
import { configure, getLogger } from "log4js";
configure("./filename");
const logger = getLogger();
logger.level = 'debug';
logger.level = "debug";
logger.debug("Some debug messages");
configure({
appenders: { cheese: { type: 'file', filename: 'cheese.log' } },
categories: { default: { appenders: ['cheese'], level: 'error' } }
appenders: { cheese: { type: "file", filename: "cheese.log" } },
categories: { default: { appenders: ["cheese"], level: "error" } }
});
```

View File

@ -11,18 +11,19 @@ There have been a few changes between log4js 1.x and 2.x (and 0.x too). You shou
## Features
* coloured console logging to [stdout](stdout.md) or [stderr](stderr.md)
* [file appender](file.md), with configurable log rolling based on file size or [date](dateFile.md)
* [SMTP appender](https://github.com/log4js-node/smtp)
* [GELF appender](https://github.com/log4js-node/gelf)
* [Loggly appender](https://github.com/log4js-node/loggly)
* [Logstash UDP appender](https://github.com/log4js-node/logstashUDP)
* logFaces ([UDP](logFaces-UDP.md) and [HTTP](logFaces-HTTP.md)) appender
* [TCP appender](tcp.md) (useful when you've got multiple servers but want to centralise logging)
* a [logger for connect/express](connect-logger.md) servers
* configurable log message [layout/patterns](layouts.md)
* different log levels for different log categories (make some parts of your app log as DEBUG, others only ERRORS, etc.)
* built-in support for logging with node core's `cluster` module
- coloured console logging to [stdout](stdout.md) or [stderr](stderr.md)
- [file appender](file.md), with configurable log rolling based on file size or [date](dateFile.md)
- [SMTP appender](https://github.com/log4js-node/smtp)
- [GELF appender](https://github.com/log4js-node/gelf)
- [Loggly appender](https://github.com/log4js-node/loggly)
- [Logstash UDP appender](https://github.com/log4js-node/logstashUDP)
- logFaces ([UDP](logFaces-UDP.md) and [HTTP](logFaces-HTTP.md)) appender
- [TCP appender](tcp.md) (useful when you've got multiple servers but want to centralise logging)
- a [logger for connect/express](connect-logger.md) servers
- configurable log message [layout/patterns](layouts.md)
- different log levels for different log categories (make some parts of your app log as DEBUG, others only ERRORS, etc.)
- built-in support for logging with node core's `cluster` module
- third-party [InfluxDB appender](https://github.com/rnd-debug/log4js-influxdb-appender)
## Installation
@ -33,14 +34,16 @@ npm install log4js
## Usage
Minimalist version:
```javascript
var log4js = require('log4js');
var log4js = require("log4js");
var logger = log4js.getLogger();
logger.level = 'debug'; // default level is OFF - which means no logs at all.
logger.level = "debug"; // default level is OFF - which means no logs at all.
logger.debug("Some debug messages");
```
## Clustering
If you use node's cluster, or passenger, or pm2, then you should read this [clustering guide](clustering.md)
## Note for library makers