mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
docs(multiprocess): added multiprocess docs
This commit is contained in:
parent
bb271eb3d1
commit
89c8ff7043
38
docs/multiprocess.md
Normal file
38
docs/multiprocess.md
Normal file
@ -0,0 +1,38 @@
|
||||
# Multiprocess Appender
|
||||
|
||||
The multiprocess appender sends log events to a master server over TCP sockets. It can be used as a simple way to centralise logging when you have multiple servers or processes. It uses the node.js core networking modules, and so does not require any extra dependencies. Remember to call `log4js.shutdown` when your application terminates, so that the sockets get closed cleanly.
|
||||
|
||||
## Configuration
|
||||
|
||||
* `type` - `multiprocess`
|
||||
* `mode` - `master|worker` - controls whether the appender listens for log events sent over the network, or is responsible for serialising events and sending them to a server.
|
||||
* `appender` - `string` (only needed if `mode` == `master`)- the name of the appender to send the log events to
|
||||
* `loggerPort` - `integer` (optional, defaults to `5000`) - the port to listen on, or send to
|
||||
* `loggerHost` - `string` (optional, defaults to `localhost`) - the host/IP address to listen on, or send to
|
||||
|
||||
## Example (master)
|
||||
```javascript
|
||||
log4js.configure({
|
||||
appenders: {
|
||||
file: { type: 'file', filename: 'all-the-logs.log' },
|
||||
server: { type: 'multiprocess', mode: 'master', appender: 'file', loggerHost: '0.0.0.0' }
|
||||
},
|
||||
categories: {
|
||||
default: { appenders: ['file'], level: 'info' }
|
||||
}
|
||||
});
|
||||
```
|
||||
This creates a log server listening on port 5000, on all IP addresses the host has assigned to it. Note that the appender is not included in the appenders listed for the categories. Also note that the multiprocess master appender will send every event it receives to the underlying appender, regardless of level settings.
|
||||
|
||||
## Example (worker)
|
||||
```javascript
|
||||
log4js.configure({
|
||||
appenders: {
|
||||
network: { type: 'multiprocess', mode: 'worker', loggerHost: 'log.server' }
|
||||
},
|
||||
categories: {
|
||||
default: { appenders: ['network'], level: 'error' }
|
||||
}
|
||||
});
|
||||
```
|
||||
This will send all error messages to `log.server:5000`.
|
||||
Loading…
x
Reference in New Issue
Block a user