8000 Merge pull request #1014 from rnd-debug/docs-influxAppender · xaviernoder/log4js-node@4937367 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4937367

Browse files
authored
Merge pull request log4js-node#1014 from rnd-debug/docs-influxAppender
docs: adding mention of InfluxDB appender
2 parents a6eca3e + 8d2f69c commit 4937367

File tree

2 files changed

+60
-47
lines changed

2 files changed

+60
-47
lines changed

README.md

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# 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)
22

3-
43
[![NPM](https://nodei.co/npm/log4js.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/log4js/)
54

65
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
1413

1514
Out of the box it supports the following features:
1615

17-
* coloured console logging to stdout or stderr
18-
* file appender, with configurable log rolling based on file size or date
19-
* a logger for connect/express servers
20-
* configurable log message layout/patterns
21-
* different log levels for different log categories (make some parts of your app log as DEBUG, others only ERRORS, etc.)
16+
- coloured console logging to stdout or stderr
17+
- file appender, with configurable log rolling based on file size or date
18+
- a logger for connect/express servers
19+
- configurable log message layout/patterns
20+
- different log levels for different log categories (make some parts of your app log as DEBUG, others only ERRORS, etc.)
2221

2322
Optional appenders are available:
24-
* [SMTP](https://github.com/log4js-node/smtp)
25-
* [GELF](https://github.com/log4js-node/gelf)
26-
* [Loggly](https://github.com/log4js-node/loggly)
27-
* Logstash ([UDP](https://github.com/log4js-node/logstashUDP) and [HTTP](https://github.com/log4js-node/logstashHTTP))
28-
* logFaces ([UDP](https://github.com/log4js-node/logFaces-UDP) and [HTTP](https://github.com/log4js-node/logFaces-HTTP))
29-
* [RabbitMQ](https://github.com/log4js-node/rabbitmq)
30-
* [Redis](https://github.com/log4js-node/redis)
31-
* [Hipchat](https://github.com/log4js-node/hipchat)
32-
* [Slack](https://github.com/log4js-node/slack)
33-
* [mailgun](https://github.com/log4js-node/mailgun)
3423

24+
- [SMTP](https://github.com/log4js-node/smtp)
25+
- [GELF](https://github.com/log4js-node/gelf)
26+
- [Loggly](https://github.com/log4js-node/loggly)
27+
- Logstash ([UDP](https://github.com/log4js-node/logstashUDP) and [HTTP](https://github.com/log4js-node/logstashHTTP))
28+
- logFaces ([UDP](https://github.com/log4js-node/logFaces-UDP) and [HTTP](https://github.com/log4js-node/logFaces-HTTP))
29+
- [RabbitMQ](https://github.com/log4js-node/rabbitmq)
30+
- [Redis](https://github.com/log4js-node/redis)
31+
- [Hipchat](https://github.com/log4js-node/hipchat)
32+
- [Slack](https://github.com/log4js-node/slack)
33+
- [mailgun](https://github.com/log4js-node/mailgun)
34+
- [InfluxDB](https://github.com/rnd-debug/log4js-influxdb-appender)
3535

3636
## Getting help
37+
3738
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.
3839

3940
## installation
@@ -45,33 +46,40 @@ npm install log4js
4546
## usage
4647

4748
Minimalist version:
49+
4850
```javascript
49-
var log4js = require('log4js');
51+
var log4js = require("log4js");
5052
var logger = log4js.getLogger();
51-
logger.level = 'debug';
53+
logger.level = "debug";
5254
logger.debug("Some debug messages");
5355
```
56+
5457
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:
58+
5559
```bash
5660
[2010-01-17 11:43:37.987] [DEBUG] [default] - Some debug messages
5761
```
62+
5863
See example.js for a full example, but here's a snippet (also in `examples/fromreadme.js`):
64+
5965
```javascript
60-
const log4js = require('log4js');
66+
const log4js = require("log4js");
6167
log4js.configure({
62-
appenders: { cheese: { type: 'file', filename: 'cheese.log' } },
63-
categories: { default: { appenders: ['cheese'], level: 'error' } }
68+
appenders: { cheese: { type: "file", filename: "cheese.log" } },
69+
categories: { default: { appenders: ["cheese"], level: "error" } }
6470
});
6571

66-
const logger = log4js.getLogger('cheese');
67-
logger.trace('Entering cheese testing');
68-
logger.debug('Got cheese.');
69-
logger.info('Cheese is Comté.');
70-
logger.warn('Cheese is quite smelly.');
71-
logger.error('Cheese is too ripe!');
72-
logger.fatal('Cheese was breeding ground for listeria.');
72+
const logger = log4js.getLogger("cheese");
73+
logger.trace("Entering cheese testing");
74+
logger.debug("Got cheese.");
75+
logger.info("Cheese is Comté.");
76+
logger.warn("Cheese is quite smelly.");
77+
logger.error("Cheese is too ripe!");
78+
logger.fatal("Cheese was breeding ground for listeria.");
7379
```
80+
7481
Output (in `cheese.log`):
82+
7583
```bash
7684
[2010-01-17 11:43:37.987] [ERROR] cheese - Cheese is too ripe!
7785
[2010-01-17 11:43:37.990] [FATAL] cheese - Cheese was breeding ground for listeria.
@@ -82,21 +90,23 @@ Output (in `cheese.log`):
8290
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).
8391

8492
## Documentation
93+
8594
Available [here](https://log4js-node.github.io/log4js-node/).
8695

8796
There's also [an example application](https://github.com/log4js-node/log4js-example).
8897

8998
## TypeScript
99+
90100
```ts
91-
import { configure, getLogger } from 'log4js';
92-
configure('./filename');
101+
import { configure, getLogger } from "log4js";
102+
configure("./filename");
93103
const logger = getLogger();
94-
logger.level = 'debug';
104+
logger.level = "debug";
95105
logger.debug("Some debug messages");
96106

97107
configure({
98-
appenders: { cheese: { type: 'file', filename: 'cheese.log' } },
99-
categories: { default: { appenders: ['cheese'], level: 'error' } }
108+
appenders: { cheese: { type: "file", filename: "cheese.log" } },
109+
categories: { default: { appenders: ["cheese"], level: "error" } }
100110
});
101111
```
102112

docs/index.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@ There have been a few changes between log4js 1.x and 2.x (and 0.x too). You shou
1111

1212
## Features
1313

14-
* coloured console logging to [stdout](stdout.md) or [stderr](stderr.md)
15-
* [file appender](file.md), with configurable log rolling based on file size or [date](dateFile.md)
16-
* [SMTP appender](https://github.com/log4js-node/smtp)
17-
* [GELF appender](https://github.com/log4js-node/gelf)
18-
* [Loggly appender](https://github.com/log4js-node/loggly)
19-
* [Logstash UDP appender](https://github.com/log4js-node/logstashUDP)
20-
* logFaces ([UDP](logFaces-UDP.md) and [HTTP](logFaces-HTTP.md)) appender
21-
* [TCP appender](tcp.md) (useful when you've got multiple servers but want to centralise logging)
22-
* a [logger for connect/express](connect-logger.md) servers
23-
* configurable log message [layout/patterns](layouts.md)
24-
* different log levels for different log categories (make some parts of your app log as DEBUG, others only ERRORS, etc.)
25-
* built-in support for logging with node core's `cluster` module
14+
- coloured console logging to [stdout](stdout.md) or [stderr](stderr.md)
15+
- [file appender](file.md), with configurable log rolling based on file size or [date](dateFile.md)
16+
- [SMTP appender](https://github.com/log4js-node/smtp)
17+
- [GELF appender](https://github.com/log4js-node/gelf)
18+
- [Loggly appender](https://github.com/log4js-node/loggly)
19+
- [Logstash UDP appender](https://github.com/log4js-node/logstashUDP)
20+
- logFaces ([UDP](logFaces-UDP.md) and [HTTP](logFaces-HTTP.md)) appender
21+
- [TCP appender](tcp.md) (useful when you've got multiple servers but want to centralise logging)
22+
- a [logger for connect/express](connect-logger.md) servers
23+
- configurable log message [layout/patterns](layouts.md)
24+
- different log levels for different log categories (make some parts of your app log as DEBUG, others only ERRORS, etc.)
25+
- built-in support for logging with node core's `cluster` module
26+
- third-party [InfluxDB appender](https://github.com/rnd-debug/log4js-influxdb-appender)
2627

2728
## Installation
2829

@@ -33,14 +34,16 @@ npm install log4js
3334
## Usage
3435

3536
Minimalist version:
37+
3638
```javascript
37-
var log4js = require('log4js');
39+
var log4js = require("log4js");
3840
var logger = log4js.getLogger();
39-
logger.level = 'debug'; // default level is OFF - which means no logs at all.
41+
logger.level = "debug"; // default level is OFF - which means no logs at all.
4042
logger.debug("Some debug messages");
4143
```
4244

4345
## Clustering
46+
4447
If you use node's cluster, or passenger, or pm2, then you should read this [clustering guide](clustering.md)
4548

4649
## Note for library makers

0 commit comments

Comments
 (0)
0