source: trip-planner-front/node_modules/log4js/README.md@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.3 KB
Line 
1# 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)
2
3[![NPM](https://nodei.co/npm/log4js.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/log4js/)
4
5This is a conversion of the [log4js](https://github.com/stritti/log4js)
6framework to work with [node](http://nodejs.org). I started out just stripping out the browser-specific code and tidying up some of the javascript to work better in node. It grew from there. Although it's got a similar name to the Java library [log4j](https://logging.apache.org/log4j/2.x/), thinking that it will behave the same way will only bring you sorrow and confusion.
7
8The full documentation is available [here](https://log4js-node.github.io/log4js-node/).
9
10[Changes in version 3.x](https://log4js-node.github.io/log4js-node/v3-changes.md)
11
12There have been a few changes between log4js 1.x and 2.x (and 0.x too). You should probably read this [migration guide](https://log4js-node.github.io/log4js-node/migration-guide.html) if things aren't working.
13
14Out of the box it supports the following features:
15
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.)
21
22Optional appenders are available:
23
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)
35
36## Getting help
37
38Having 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.
39
40## installation
41
42```bash
43npm install log4js
44```
45
46## usage
47
48Minimalist version:
49
50```javascript
51var log4js = require("log4js");
52var logger = log4js.getLogger();
53logger.level = "debug";
54logger.debug("Some debug messages");
55```
56
57By 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
59```bash
60[2010-01-17 11:43:37.987] [DEBUG] [default] - Some debug messages
61```
62
63See example.js for a full example, but here's a snippet (also in `examples/fromreadme.js`):
64
65```javascript
66const log4js = require("log4js");
67log4js.configure({
68 appenders: { cheese: { type: "file", filename: "cheese.log" } },
69 categories: { default: { appenders: ["cheese"], level: "error" } }
70});
71
72const logger = log4js.getLogger("cheese");
73logger.trace("Entering cheese testing");
74logger.debug("Got cheese.");
75logger.info("Cheese is Comté.");
76logger.warn("Cheese is quite smelly.");
77logger.error("Cheese is too ripe!");
78logger.fatal("Cheese was breeding ground for listeria.");
79```
80
81Output (in `cheese.log`):
82
83```bash
84[2010-01-17 11:43:37.987] [ERROR] cheese - Cheese is too ripe!
85[2010-01-17 11:43:37.990] [FATAL] cheese - Cheese was breeding ground for listeria.
86```
87
88## Note for library makers
89
90If 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).
91
92## Documentation
93
94Available [here](https://log4js-node.github.io/log4js-node/).
95
96There's also [an example application](https://github.com/log4js-node/log4js-example).
97
98## TypeScript
99
100```ts
101import { configure, getLogger } from "log4js";
102configure("./filename");
103const logger = getLogger();
104logger.level = "debug";
105logger.debug("Some debug messages");
106
107configure({
108 appenders: { cheese: { type: "file", filename: "cheese.log" } },
109 categories: { default: { appenders: ["cheese"], level: "error" } }
110});
111```
112
113## Contributing
114
115We're always looking for people to help out. Jump on [slack](https://join.slack.com/t/log4js-node/shared_invite/enQtODkzMDQ3MzExMDczLWUzZmY0MmI0YWI1ZjFhODY0YjI0YmU1N2U5ZTRkOTYyYzg3MjY5NWI4M2FjZThjYjdiOGM0NjU2NzBmYTJjOGI) and discuss what you want to do. Also, take a look at the [rules](https://log4js-node.github.io/log4js-node/contrib-guidelines.html) before submitting a pull request.
116
117## License
118
119The original log4js was distributed under the Apache 2.0 License, and so is this. I've tried to
120keep the original copyright and author credits in place, except in sections that I have rewritten
121extensively.
Note: See TracBrowser for help on using the repository browser.