You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a conversion of the [log4js](https://github.com/stritti/log4js)
6
-
framework to work with [node](http://nodejs.org). I've mainly stripped out the browser-specific code and tidied up some of the javascript.
6
+
framework to work with [node](http://nodejs.org). I've mainly stripped out the browser-specific code and tidied up some of the javascript.
7
7
8
8
Out of the box it supports the following features:
9
9
10
10
* coloured console logging to stdout or stderr
11
11
* replacement of node's console.log functions (optional)
12
-
* file appender, with log rolling based on file size
12
+
* file appender, with configurable log rolling based on file size or date
13
13
* SMTP appender
14
14
* GELF appender
15
-
* hook.io appender
16
15
* Loggly appender
17
16
* Logstash UDP appender
18
17
* logFaces appender
@@ -21,6 +20,12 @@ Out of the box it supports the following features:
21
20
* configurable log message layout/patterns
22
21
* different log levels for different log categories (make some parts of your app log as DEBUG, others only ERRORS, etc.)
23
22
23
+
## Important changes in 1.0
24
+
25
+
The default appender has been changed from `console` to `stdout` - this alleviates a memory problem that happens when logging using console. If you're using log4js in a browser (via browserify), then you'll probably need to explicitly configure log4js to use the console appender now (unless browserify handles process.stdout).
26
+
27
+
I'm also trying to move away from `vows` for the tests, and use `tape` instead. New tests should be added to `test/tape`, not the vows ones.
28
+
24
29
NOTE: from log4js 0.5 onwards you'll need to explicitly enable replacement of node's console.log functions. Do this either by calling `log4js.replaceConsole()` or configuring with an object or json file like this:
25
30
26
31
```javascript
@@ -51,7 +56,7 @@ By default, log4js outputs to stdout with the coloured layout (thanks to [masylu
51
56
```
52
57
See example.js for a full example, but here's a snippet (also in fromreadme.js):
53
58
```javascript
54
-
var log4js =require('log4js');
59
+
var log4js =require('log4js');
55
60
//console log is loaded by default, so you won't normally need to do this
56
61
//log4js.loadAppender('console');
57
62
log4js.loadAppender('file');
@@ -87,9 +92,9 @@ log4js.configure({
87
92
## configuration
88
93
89
94
You can configure the appenders and log levels manually (as above), or provide a
90
-
configuration file (`log4js.configure('path/to/file.json')`), or a configuration object. The
91
-
configuration file location may also be specified via the environment variable
An example file can be found in `test/log4js.json`. An example config file with log rolling is in `test/with-log-rolling.json`.
94
99
You can configure log4js to check for configuration file changes at regular intervals, and if changed, reload. This allows changes to logging levels to occur without restarting the application.
0 commit comments