First working version

tried examples/loggly-appender.js [OK]
This commit is contained in:
Christiaan Westerbeek 2014-01-10 21:51:08 +01:00
parent 5286c50375
commit eb51aa99be
2 changed files with 19 additions and 14 deletions

View File

@ -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");
//logger.debug("Test log message");

View File

@ -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));
}
});
};
}