From 89c8ff7043ccf9bb357d024cb65c10ffe786cea2 Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Mon, 8 May 2017 09:00:09 +1000 Subject: [PATCH] docs(multiprocess): added multiprocess docs --- docs/multiprocess.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 docs/multiprocess.md diff --git a/docs/multiprocess.md b/docs/multiprocess.md new file mode 100644 index 0000000..2fc3fb0 --- /dev/null +++ b/docs/multiprocess.md @@ -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`.