# graylog2

> Graylog2 client library for node.js

Latest version **0.2.1** (published 2018-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install graylog2
pnpm add graylog2
yarn add graylog2
bun add graylog2
```

## 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.2.1 |
| Published | 2018-02-05 |
| First published | 2012-10-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/graylog2) |
| Module format | CommonJS |
| Node | >=0.6.11 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 59 |
| Author | Marc Trudel-Belise |
| Maintainers | notawizard, stelcheck, ronkorving |

## Links

- npm: https://www.npmjs.com/package/graylog2
- Repository: https://github.com/Wizcorp/node-graylog2
- Homepage: http://github.com/Wizcorp/node-graylog2
- Issues: http://github.com/Wizcorp/node-graylog2/issues
- npm.io page: https://npm.io/package/graylog2

## Recent versions

- 0.2.1 (latest) — 2018-02-05
- 0.2.0 — 2017-09-20
- 0.1.3 — 2014-07-16
- 0.1.2 — 2014-03-03
- 0.1.1 — 2013-10-29
- 0.1.0 — 2013-09-05
- 0.0.2 — 2012-10-10
- 0.0.1 — 2012-10-04

## README

# node-graylog2
[![NPM version](http://img.shields.io/npm/v/graylog2.svg?style=flat-square)](https://www.npmjs.org/package/graylog2) [![NPM license](http://img.shields.io/npm/l/graylog2.svg?style=flat-square)](https://www.npmjs.org/package/graylog2)

Graylog2 client library for Node.js, based on node-graylog. This
has been heavily modified to the point where there is not much left
of the original; however, this library should still be compatible
with the old one, except for configuration and the GLOBAL function setup
(some optional arguments in logging calls are not supported; they will be
logged as additional data).

** New: ** Chunked [GELF](https://github.com/Graylog2/graylog2-docs/wiki/GELF)
is now supported.

## Synopsis

### Available functions

* graylog.emergency
* graylog.alert
* graylog.critical
* graylog.error
* graylog.warning
* graylog.notice
* graylog.info
* graylog.debug

### Code snippets

```javascript
var graylog2 = require("graylog2");
var logger = new graylog2.graylog({
    servers: [
        { 'host': '127.0.0.1', port: 12201 },
        { 'host': '127.0.0.2', port: 12201 }
    ],
    hostname: 'server.name', // the name of this host
                             // (optional, default: os.hostname())
    facility: 'Node.js',     // the facility for these log messages
                             // (optional, default: "Node.js")
    bufferSize: 1350         // max UDP packet size, should never exceed the
                             // MTU of your system (optional, default: 1400)
});

logger.on('error', function (error) {
    console.error('Error while trying to write to graylog2:', error);
});

```

Short message:

```javascript
logger.log("What we've got here is...failure to communicate");
```

Long message:

```javascript
logger.log("What we've got here is...failure to communicate", "Some men you just can't reach. So you get what we had here last week, which is the way he wants it... well, he gets it. I don't like it any more than you men.");
```

Short with additional data:

```javascript
logger.log("What we've got here is...failure to communicate", { cool: 'beans' });
```

Long with additional data:

```javascript
logger.log("What we've got here is...failure to communicate", "Some men you just can't reach. So you get what we had here last week, which is the way he wants it... well, he gets it. I don't like it any more than you men.",
    {
        cool: "beans"
    }
);
```

Flush all log messages and close down:
```javascript
logger.close(function(){
    console.log('All done - cookie now?');
    process.exit();
});
```

## Example

See `test.js`.

## What is graylog2 after all?

It's a miracle. Get it at http://www.graylog2.org/

## Installation

    npm install graylog2

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