From 5b2d840472c331c647b69b39196ebd66a49c7388 Mon Sep 17 00:00:00 2001 From: Jens John Date: Thu, 10 Jul 2014 14:07:38 +0900 Subject: [PATCH] GELF appender: move facility key into a custom field if present At the same time, don't assign a default value as the field is optional according to the GELF spec v1.1. --- lib/appenders/gelf.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/appenders/gelf.js b/lib/appenders/gelf.js index 8e075b5..e536462 100644 --- a/lib/appenders/gelf.js +++ b/lib/appenders/gelf.js @@ -48,7 +48,9 @@ function gelfAppender (layout, host, port, hostname, facility) { host = host || 'localhost'; port = port || 12201; hostname = hostname || require('os').hostname(); - facility = facility || 'nodejs-server'; + if(facility) { + customFields['_facility'] = facility; + } layout = layout || layouts.messagePassThroughLayout; var defaultCustomFields = customFields || {}; @@ -103,7 +105,6 @@ function gelfAppender (layout, host, port, hostname, facility) { msg.timestamp = msg.timestamp || new Date().getTime() / 1000; // log should use millisecond msg.host = hostname; msg.level = levelMapping[loggingEvent.level || levels.DEBUG]; - msg.facility = facility; return msg; }