First working version
tried examples/loggly-appender.js [OK]
This commit is contained in:
parent
5286c50375
commit
eb51aa99be
@ -1,10 +1,8 @@
|
|||||||
//Note that loggly appender needs node-loggly to work.
|
//Note that loggly appender needs node-loggly to work.
|
||||||
//If you haven't got node-loggly installed, you'll get cryptic
|
//If you haven't got node-loggly installed, you'll get cryptic
|
||||||
//"cannot find module" errors when using the loggly appender
|
//"cannot find module" errors when using the loggly appender
|
||||||
var log4js = require('../lib/log4js')
|
var log4js = require('../lib/log4js');
|
||||||
, log
|
|
||||||
, logmailer
|
|
||||||
, i = 0;
|
|
||||||
log4js.configure({
|
log4js.configure({
|
||||||
"appenders": [
|
"appenders": [
|
||||||
{
|
{
|
||||||
@ -16,11 +14,11 @@ log4js.configure({
|
|||||||
"token" : "12345678901234567890",
|
"token" : "12345678901234567890",
|
||||||
"subdomain": "your-subdomain",
|
"subdomain": "your-subdomain",
|
||||||
"tags" : ["test"],
|
"tags" : ["test"],
|
||||||
"category": "test"
|
"category" : "loggly"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
var logger = log4js.getLogger("test");
|
var logger = log4js.getLogger("loggly");
|
||||||
logger.info("Test log message");
|
logger.info("Test log message");
|
||||||
logger.debug("Test log message");
|
//logger.debug("Test log message");
|
@ -1,6 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var layouts = require("../layouts")
|
var layouts = require("../layouts")
|
||||||
, mailer = require("loggly")
|
, loggly = require("loggly")
|
||||||
, os = require('os');
|
, os = require('os');
|
||||||
|
|
||||||
|
|
||||||
@ -22,7 +22,14 @@ function logglyAppender(config, layout) {
|
|||||||
|
|
||||||
|
|
||||||
return function(loggingEvent) {
|
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));
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user