Remove GELF flag when capturing custom fields

* Logstash (which supports GELF) drops messages with this key
* There's no particular need to keep this key
master
Skylar Lowery 10 years ago
parent 9fe32d06e3
commit 3cf1d697e8

@ -85,6 +85,8 @@ function gelfAppender (layout, host, port, hostname, facility) {
var firstData = data[0];
if (!firstData.GELF) return; // identify with GELF field defined
// Remove the GELF key, some gelf supported logging systems drop the message with it
delete firstData.GELF;
Object.keys(firstData).forEach(function(key) {
// skip _id field for graylog2, skip keys not starts with UNDERSCORE
if (key.match(/^_/) || key !== "_id") {

@ -244,6 +244,7 @@ vows.describe('log4js gelfAppender').addBatch({
},
'should pick up the options': function(message) {
assert.equal(message.host, 'cheese');
assert.equal(message.GELF, void(0)); // make sure flag was removed
assert.equal(message._facility, 'nonsense');
assert.equal(message._every1, 'Hello every one'); // the default value
assert.equal(message._every2, 'Overwritten!'); // the overwritten value

Loading…
Cancel
Save