Merge branch 'master' into version-3.x

This commit is contained in:
Gareth Jones 2018-07-12 17:06:01 +10:00
commit 2db6bb036c
4 changed files with 13 additions and 38 deletions

View File

@ -24,7 +24,6 @@ The following appenders are included with log4js. Some require extra dependencie
* [dateFile](dateFile.md)
* [file](file.md)
* [fileSync](fileSync.md)
* [logFaces-UDP](logFaces-UDP.md)
* [logLevelFilter](logLevelFilter.md)
* [multiFile](multiFile.md)
* [multiprocess](multiprocess.md)
@ -41,6 +40,7 @@ The following appenders are supported by log4js, but are no longer distributed w
* [gelf](https://github.com/log4js-node/gelf)
* [hipchat](https://github.com/log4js-node/hipchat)
* [logFaces-HTTP](https://github.com/log4js-node/logFaces-HTTP)
* [logFaces-UDP](https://github.com/log4js-node/logFaces-UDP)
* [loggly](https://github.com/log4js-node/loggly)
* [logstashHTTP](https://github.com/log4js-node/logstashHTTP)
* [logstashUDP](https://github.com/log4js-node/logstashUDP)

View File

@ -1,31 +0,0 @@
# logFaces Appender (UDP)
The logFaces appenders send JSON formatted log events to [logFaces](http://www.moonlit-software.com) receivers. This appender uses UDP to send the events (there is another logFaces appender that uses [HTTP](logFaces-HTTP.md)). It uses the node.js core UDP support, so you do not need to include any other dependencies.
## Configuration
* `type` - `logFaces-UDP`
* `remoteHost` - `string` (optional, defaults to '127.0.0.1')- hostname or IP address of the logFaces receiver
* `port` - `integer` (optional, defaults to 55201) - port the logFaces receiver is listening on
* `application` - `string` (optional, defaults to empty string) - used to identify your application's logs
This appender will also pick up Logger context values from the events, and add them as `p_` values in the logFaces event. See the example below for more details.
# Example (default config)
```javascript
log4js.configure({
appenders: {
logfaces: { type: 'logFaces-UDP' }
},
categories: {
default: { appenders: [ 'logfaces' ], level: 'info' }
}
});
const logger = log4js.getLogger();
logger.addContext('requestId', '123');
logger.info('some interesting log message');
logger.error('something has gone wrong');
```
This example will result in two log events being sent via UDP to `127.0.0.1:55201`. Both events will have a `p_requestId` property with a value of `123`.

View File

@ -8,11 +8,11 @@ const log4js = require('../lib/log4js');
log4js.configure({
appenders: {
logFaces: {
type: 'logFaces-UDP', // (mandatory) appender type
application: 'MY-NODEJS', // (optional) name of the application (domain)
remoteHost: 'localhost', // (optional) logFaces server host or IP address
port: 55201, // (optional) logFaces UDP receiver port (must use JSON format)
layout: { // (optional) the layout to use for messages
type: '@log4js-node/logfaces-udp', // (mandatory) appender type
application: 'MY-NODEJS', // (optional) name of the application (domain)
remoteHost: 'localhost', // (optional) logFaces server host or IP address
port: 55201, // (optional) logFaces UDP receiver port (must use JSON format)
layout: { // (optional) the layout to use for messages
type: 'pattern',
pattern: '%m'
}

View File

@ -1,4 +1,7 @@
/**
* This appender has been deprecated. Any bug fixes or improvements should be
* made against https://github.com/log4js-node/logFaces-UDP
*
* logFaces appender sends JSON formatted log events to logFaces receivers.
* There are two types of receivers supported - raw UDP sockets (for server side apps),
* and HTTP (for client side apps). Depending on the usage, this appender
@ -43,7 +46,7 @@ function datagram(config) {
function logFacesUDPAppender(config) {
const send = datagram(config);
return function log(event) {
const appender = function log(event) {
// convert to logFaces compact json format
const lfsEvent = {
a: config.application || '', // application name
@ -61,6 +64,9 @@ function logFacesUDPAppender(config) {
// send to server
send(lfsEvent);
};
appender.deprecated = '@log4js-node/logfaces-udp';
return appender;
}
function configure(config) {