diff --git a/examples/loggly-appender.js b/examples/loggly-appender.js index 9a7bc54..1465c92 100644 --- a/examples/loggly-appender.js +++ b/examples/loggly-appender.js @@ -1,10 +1,8 @@ //Note that loggly appender needs node-loggly to work. //If you haven't got node-loggly installed, you'll get cryptic //"cannot find module" errors when using the loggly appender -var log4js = require('../lib/log4js') -, log -, logmailer -, i = 0; +var log4js = require('../lib/log4js'); + log4js.configure({ "appenders": [ { @@ -12,15 +10,15 @@ log4js.configure({ category: "test" }, { - "type": "loggly", - "token": "12345678901234567890", + "type" : "loggly", + "token" : "12345678901234567890", "subdomain": "your-subdomain", - "tags": ["test"], - "category": "test" + "tags" : ["test"], + "category" : "loggly" } ] }); -var logger = log4js.getLogger("test"); +var logger = log4js.getLogger("loggly"); logger.info("Test log message"); -logger.debug("Test log message"); \ No newline at end of file +//logger.debug("Test log message"); \ No newline at end of file diff --git a/lib/appenders/loggly.js b/lib/appenders/loggly.js index eccca02..7f7df8f 100644 --- a/lib/appenders/loggly.js +++ b/lib/appenders/loggly.js @@ -1,6 +1,6 @@ "use strict"; var layouts = require("../layouts") -, mailer = require("loggly") +, loggly = require("loggly") , os = require('os'); @@ -22,7 +22,14 @@ function logglyAppender(config, layout) { return function(loggingEvent) { - client.log(layout(loggingEvent)); + console.log('attempts', loggingEvent, layout(loggingEvent), config.tags); + client.log(layout(loggingEvent), config.tags, function(err, result){ + if (err) { + console.log('Loggly: '+ err.message); + } else { + console.log('Loggly: '+ JSON.stringify(result)); + } + }); }; } @@ -35,6 +42,6 @@ function configure(config) { return logglyAppender(config, layout); } -exports.name = "loggly"; -exports.appender = logglyAppender; +exports.name = "loggly"; +exports.appender = logglyAppender; exports.configure = configure; \ No newline at end of file