From a376f633ff47c35a831cf5a8a0bfbe0a09b54e9b Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Thu, 8 Mar 2018 07:52:57 +1100 Subject: [PATCH] chore: deprecated logstashUDP --- docs/appenders.md | 2 +- docs/logstashUDP.md | 54 ------------------------------------ lib/appenders/logstashUDP.js | 1 + 3 files changed, 2 insertions(+), 55 deletions(-) delete mode 100644 docs/logstashUDP.md diff --git a/docs/appenders.md b/docs/appenders.md index 936a64c..2a2de16 100644 --- a/docs/appenders.md +++ b/docs/appenders.md @@ -28,7 +28,6 @@ The following appenders are included with log4js. Some require extra dependencie * [logFaces-UDP](logFaces-UDP.md) * [logLevelFilter](logLevelFilter.md) * [logstashHTTP](logstashHTTP.md) -* [logstashUDP](logstashUDP.md) * [mailgun](mailgun.md) * [multiFile](multiFile.md) * [multiprocess](multiprocess.md) @@ -47,6 +46,7 @@ The following appenders are supported by log4js, but will issue deprecation warn * [gelf](https://github.com/log4js-node/gelf) * [hipchat](https://github.com/log4js-node/hipchat) * [loggly](https://github.com/log4js-node/loggly) +* [logstashUDP](https://github.com/log4js-node/logstashUDP) For example, if you were previously using the gelf appender (`type: 'gelf'`) then you should add `@log4js-node/gelf` to your dependencies and change the type to `type: '@log4js-node/gelf'`. diff --git a/docs/logstashUDP.md b/docs/logstashUDP.md deleted file mode 100644 index a50e82f..0000000 --- a/docs/logstashUDP.md +++ /dev/null @@ -1,54 +0,0 @@ -# Logstash UDP Appender - -This appender sends log events to a [logstash](https://www.elastic.co/products/logstash) server via UDP. It uses the node.js core UDP support, and so requires no extra dependencies. Remember to call `log4js.shutdown` in your application if you want the UDP socket closed cleanly. - -## Configuration - -* `type` - `logstashUDP` -* `host` - `string` - hostname (or IP-address) of the logstash server -* `port` - `integer` - port of the logstash server -* `logType` - `string` (optional) - used for the `type` field in the logstash data -* `category` - `string` (optional) - used for the `type` field of the logstash data if `logType` is not defined -* `fields` - `object` (optional) - extra fields to log with each event. User-defined fields can be either a string or a function. Functions will be passed the log event, and should return a string. -* `layout` - (optional, defaults to dummyLayout) - used for the `message` field of the logstash data (see [layouts](layouts.md)) -* `args` - (optional, defaults to both) - determines how to log arguments and configuration fields: `direct` logs them as direct properties of the log object, `fields` logs them as child properties of the `fields` property, and `both` logs both. - -## Example -```javascript -log4js.configure({ - appenders: { - logstash: { - type: 'logstashUDP', - host: 'log.server', - port: '12345', - logType: 'application', - fields: { biscuits: 'digestive', tea: 'tetley', user: function(logEvent) { - return AuthLibrary.currentUser(); - } - } - } - }, - categories: { - default: { appenders: ['logstash'], level: 'info' } - } -}); -const logger = log4js.getLogger(); -logger.info("important log message", { cheese: 'gouda', biscuits: 'hobnob' }); -``` -This will result in a JSON message being sent to `log.server:12345` over UDP, with the following format: -```javascript -{ - '@version': '1', - '@timestamp': '2014-04-22T23:03:14.111Z', - 'type': 'application', - 'message': 'important log message', - 'fields': { - 'level': 'INFO', - 'category': 'default', - 'biscuits': 'hobnob', - 'user': 'charlie', - 'cheese': 'gouda', - 'tea': 'tetley' - } -} -``` diff --git a/lib/appenders/logstashUDP.js b/lib/appenders/logstashUDP.js index eee85aa..aefbca3 100755 --- a/lib/appenders/logstashUDP.js +++ b/lib/appenders/logstashUDP.js @@ -95,6 +95,7 @@ function logstashUDP(config, layout) { udp.close(cb); }; + log.deprecated = '@log4js-node/logstashudp'; return log; }