# splunk-logging

> Splunk HTTP Event Collector logging interface

Latest version **0.11.1** (published 2021-08-05) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install splunk-logging
pnpm add splunk-logging
yarn add splunk-logging
bun add splunk-logging
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.11.1 |
| Published | 2021-08-05 |
| First published | 2015-09-22 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | separate (@types/splunk-logging) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 55.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 91 |
| Author | Splunk |
| Maintainers | splunkdev |
| Keywords | splunk, HTTP, event, collector, logging, stream |

## Links

- npm: https://www.npmjs.com/package/splunk-logging
- Repository: https://github.com/splunk/splunk-javascript-logging
- Homepage: http://dev.splunk.com
- Issues: https://github.com/splunk/splunk-javascript-logging/issues
- npm.io page: https://npm.io/package/splunk-logging

## Dependencies (1)

- [needle](https://npm.io/package/needle.md) ^2.6.0

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 0.11.1 (latest) — 2021-08-05
- 0.11.0 — 2021-07-28
- 0.0.1-beta — 2021-06-29
- 0.10.1 — 2018-11-12
- 0.10.0 — 2018-11-12
- 0.9.3 — 2017-04-20
- 0.9.2 — 2016-11-08
- 0.9.1 — 2016-01-12
- 0.9.0 — 2015-12-10
- 0.8.0 — 2015-09-22

## README

# Splunk logging for JavaScript

#### Version 0.11.1

This project provides a simple JavaScript interface for logging to HTTP Event Collector in Splunk Enterprise and Splunk Cloud.

## Requirements

* Node.js v4 or later. Splunk logging for Javascript is tested with Node.js v10.0 and v14.0.
* Splunk Enterprise 6.3.0 or later, or Splunk Cloud. Splunk logging for Javascript is tested with Splunk Enterprise 8.0 and 8.2.0.
* An HTTP Event Collector token from your Splunk Enterprise server.

## Installation

First, update npm to the latest version by running:

    sudo npm install npm -g

Then run: 
 
    npm install --save splunk-logging

## Usage

See the `examples` folder for usage examples:

* `all_batching.js`: Shows how to configure a logger with the 3 batching settings: `batchInterval`, `maxBatchCount`, & `maxBatchSize`.
* `basic.js`: Shows how to configure a logger and send a log message to Splunk.
* `custom_format.js`: Shows how to configure a logger to log messages to Splunk using a custom format.
* `manual_batching.js`: Shows how to queue log messages, and send them in batches by manually calling `flush()`.
* `retry.js`: Shows how to configure retries on errors.

### SSL

Note: SSL certificate validation is disabled by default.
To enable it, set `requestOptions.strictSSL = true` on your `SplunkLogger` instance:

```javascript
var SplunkLogger = require("splunk-logging").Logger;

var config = {
    token: "your-token-here",
    url: "https://splunk.local:8088"
};

var Logger = new SplunkLogger(config);

// Enable SSL certificate validation
Logger.requestOptions.strictSSL = true;
```

### Basic example

```javascript
var SplunkLogger = require("splunk-logging").Logger;

var config = {
    token: "your-token-here",
    url: "https://splunk.local:8088"
};

var Logger = new SplunkLogger(config);

var payload = {
    // Message can be anything; doesn't have to be an object
    message: {
        temperature: "70F",
        chickenCount: 500
    }
};

console.log("Sending payload", payload);
Logger.send(payload, function(err, resp, body) {
    // If successful, body will be { text: 'Success', code: 0 }
    console.log("Response from Splunk", body);
});
```

## Community

Stay connected with other developers building on Splunk software.

<table>

<tr>
<td><b>Email</b></td>
<td>devinfo@splunk.com</td>
</tr>

<tr>
<td><b>Issues</b>
<td><span>https://github.com/splunk/splunk-javascript-logging/issues/</span></td>
</tr>

<tr>
<td><b>Answers</b>
<td><span>http://answers.splunk.com/</span></td>
</tr>

<tr>
<td><b>Blog</b>
<td><span>http://blogs.splunk.com/dev/</span></td>
</tr>

<tr>
<td><b>Twitter</b>
<td>@splunkdev</td>
</tr>

</table>

## Support

The Splunk logging library for JavaScript is community-supported.

1. You can find help through our community on [Splunk Answers](http://answers.splunk.com/) (use the `logging-library-javascript` tag to identify your questions).
2. File issues on [GitHub](https://github.com/splunk/splunk-javascript-logging/issues).

## Contact us

You can [contact support][contact] if you have Splunk related questions.

You can reach the Dev Platform team at [devinfo@splunk.com](mailto:devinfo@splunk.com).

## License

The Splunk Logging Library for JavaScript is licensed under the Apache
License 2.0. Details can be found in the LICENSE file.

[contact]:                  https://www.splunk.com/en_us/support-and-services.html

---
_Source: https://npm.io/package/splunk-logging · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
