
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
node-loggly-bulk
Advanced tools
A client implementation for Loggly cloud Logging-as-a-Service API
The node-loggly-bulk package is a Node.js client for Loggly, a cloud-based log management service. This package allows you to send logs to Loggly in bulk, which can be more efficient than sending logs one at a time. It supports both single and bulk log sending, and it can handle different log levels and tags.
Send a single log
This feature allows you to send a single log message to Loggly. You need to create a client with your Loggly token and subdomain, and then use the `log` method to send a log message.
const loggly = require('node-loggly-bulk');
const client = loggly.createClient({
token: 'your-really-long-input-token',
subdomain: 'your-subdomain',
tags: ['global-tag'],
json: true
});
client.log('Hello, Loggly!', function (err, result) {
if (err) {
console.error('Error sending log:', err);
} else {
console.log('Log sent:', result);
}
});
Send multiple logs in bulk
This feature allows you to send multiple log messages to Loggly in a single request. This can be more efficient than sending logs one at a time. You pass an array of log messages to the `log` method.
const loggly = require('node-loggly-bulk');
const client = loggly.createClient({
token: 'your-really-long-input-token',
subdomain: 'your-subdomain',
tags: ['global-tag'],
json: true
});
const logs = [
'First log message',
'Second log message',
'Third log message'
];
client.log(logs, function (err, result) {
if (err) {
console.error('Error sending logs:', err);
} else {
console.log('Logs sent:', result);
}
});
Send logs with different tags
This feature allows you to send a log message with custom tags. You can specify tags for individual log messages, which can be useful for categorizing and filtering logs in Loggly.
const loggly = require('node-loggly-bulk');
const client = loggly.createClient({
token: 'your-really-long-input-token',
subdomain: 'your-subdomain',
tags: ['global-tag'],
json: true
});
client.log({message: 'Log with custom tag', tags: ['custom-tag']}, function (err, result) {
if (err) {
console.error('Error sending log:', err);
} else {
console.log('Log sent:', result);
}
});
The winston-loggly-bulk package is a Loggly transport for the popular Winston logging library. It allows you to send logs to Loggly using Winston's logging interface. This package is useful if you are already using Winston for logging and want to integrate Loggly as a transport.
The bunyan-loggly package is a Loggly stream for the Bunyan logging library. It allows you to send logs to Loggly using Bunyan's logging interface. This package is useful if you are using Bunyan for structured logging and want to send your logs to Loggly.
The loggly package is another Node.js client for Loggly. It provides similar functionality to node-loggly-bulk, allowing you to send logs to Loggly. However, it does not support bulk log sending, making node-loggly-bulk more efficient for sending multiple logs at once.
A client implementation for Loggly in node.js. Check out Loggly's Node logging documentation for more.
The node-loggly-bulk
library is compliant with the Loggly API. Using node-loggly-bulk
you can send logs to Loggly.
Before we can do anything with Loggly, we have to create a client with valid credentials. We will authenticate for you automatically:
var loggly = require('node-loggly-bulk');
var client = loggly.createClient({
token: "your-really-long-input-token",
subdomain: "your-subdomain",
//
// Optional: Tag to send with EVERY log message
//
tags: ['global-tag']
});
There are two ways to send log information to Loggly via node-loggly-bulk. The first is to simply call client.log with an appropriate input token:
client.log('127.0.0.1 - There\'s no place like home', function (err, result) {
// Do something once you've logged
});
Note that the callback in the above example is optional, if you prefer the 'fire and forget' method of logging:
client.log('127.0.0.1 - There\'s no place like home');
If you're using Loggly's tags functionality, simply include an array of tags as the second argument to the log
method:
client.log('127.0.0.1 - There\'s no place like home', [ 'dorothy' ], function (err, result) {
// Do something once you've logged
});
note Tags passed into the log function will be merged with any global tags you may have defined.
In addition to logging pure strings, it is also possible to pass shallow JSON object literals (i.e. no nested objects) to client.log(..) or input.log(..) methods, which will get converted into the Loggly recommended string representation. So
var source = {
foo: 1,
bar: 2,
buzz: 3
};
input.log(source);
will be logged as:
foo=1,bar=2,buzz=3
It is also possible to log complex objects using the new JSON capabilities of Loggly. To enable JSON functionality in the client simply add 'json: true' to the configuration:
var config = {
token: 'token',
subdomain: "your-subdomain",
json: true
};
When the json flag is enabled, objects will be converted to JSON using JSON.stringify before being transmitted to Loggly. So
var source = {
foo: 1,
bar: 2,
buzz: {
sheep: 'jumped',
times: 10
}
};
input.log(source);
will be logged as:
{ "foo": 1, "bar": 2, "buzz": {"sheep": "jumped", "times": 10 }}
It is possible to send arrays, which will result in one single request to Loggly.
input.log([ {iam:'number 1'}, {iam:'number 2'} ])
$ curl http://npmjs.org/install.sh | sh
$ npm install node-loggly-bulk
$ npm run test
FAQs
A client implementation for Loggly cloud Logging-as-a-Service API
The npm package node-loggly-bulk receives a total of 194,561 weekly downloads. As such, node-loggly-bulk popularity was classified as popular.
We found that node-loggly-bulk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.