# bunyan-syslog

> Syslog Stream for Bunyan

Latest version **0.3.4** (published 2021-11-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install bunyan-syslog
pnpm add bunyan-syslog
yarn add bunyan-syslog
bun add bunyan-syslog
```

## 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.3.4 |
| Published | 2021-11-04 |
| First published | 2013-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/bunyan-syslog) |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 3 |
| Unpacked size | 18.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 67 |
| Author | Mark Cavage |
| Maintainers | todd.whiteman, kusor, wyatt, michael.hicks, bahamat, chudley, tchameroy, dbuell, pfmooney, mcavage, melloc |
| Keywords | bunyan, syslog |

## Links

- npm: https://www.npmjs.com/package/bunyan-syslog
- Repository: https://github.com/joyent/node-bunyan-syslog
- Homepage: https://github.com/joyent/node-bunyan-syslog#readme
- Issues: https://github.com/joyent/node-bunyan-syslog/issues
- npm.io page: https://npm.io/package/bunyan-syslog

## Dependencies (3)

- [nan](https://npm.io/package/nan.md) ^2.14.0
- [assert-plus](https://npm.io/package/assert-plus.md) 0.1.5
- [safer-buffer](https://npm.io/package/safer-buffer.md) ~2.1.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.3.4 (latest) — 2021-11-04
- 0.3.3 — 2019-08-20
- 0.3.2 — 2018-08-27
- 0.3.1 — 2015-11-11
- 0.3.0 — 2015-02-23
- 0.2.2 — 2013-09-17
- 0.2.1 — 2013-03-01
- 0.2.0 — 2013-01-08
- 0.1.2 — 2013-01-03
- 0.1.1 — 2013-01-03
- 0.1.0 — 2013-01-03

## README

bunyan-syslog is a stream for [bunyan](https://github.com/trentm/node-bunyan)
that consumes `raw` records from bunyan and sends them to a syslog server.

# Installation

    npm install bunyan-syslog

# Usage

```javascript
var bunyan = require('bunyan');
var bsyslog = require('bunyan-syslog');

var log = bunyan.createLogger({
	name: 'foo',
	streams: [ {
		level: 'debug',
		type: 'raw',
		stream: bsyslog.createBunyanStream({
			type: 'sys',
			facility: bsyslog.local0,
			host: '192.168.0.1',
			port: 514
		})
	}]
});

log.debug({foo: 'bar'}, 'hello %s', 'world');
```

That's pretty much it.  You create a syslog stream, and point it at a syslog
server (UDP by default; you can force TCP by setting `type: tcp` in the
constructor); default is to use facility `user` and a syslog server on
`127.0.0.1:514`.  Note you *must* pass `type: 'raw'` to bunyan in the top-level
stream object or this won't work.

If you want your logs to be in the normal bunyan format, `rsyslog` allows you to
setup a template to format it as just the JSON object:

```
template(name="bunyan" type="string"
         string="%msg:R,ERE,1,FIELD:(\\{.*\\})--end%\n")

local0.* /var/log/application.log;bunyan
```

You can also write this using the older `$template` syntax:

```
$template bunyan,"%msg:R,ERE,1,FIELD:(\{.*\})--end%\n"

local0.* /var/log/application.log;bunyan
```

## Mappings

This module maps bunyan levels to syslog levels as follows:

```
+--------+--------+
| Bunyan | Syslog |
+--------+--------+
| fatal  | emerg  |
+--------+--------+
| error  | error  |
+--------+--------+
| warn   | warn   |
+--------+--------+
| info   | info   |
+--------+--------+
| *      | debug  |
+--------+--------+
```

## Running the test suite

You can run the test suite using the provided `rsyslog` configuration:

```
$ rsyslogd -f ./test/rsyslog.conf -i $PWD/test.pid -u $USER
$ make test
$ kill $(cat test.pid)
```

If you have an older `rsyslog` installed, you can adjust it to use the legacy
syntax:

```
$ModLoad imudp
$ModLoad imtcp

$UDPServerAddress 127.0.0.1
$UDPServerRun 10514

$InputTCPServerRun 10514
```

Note that when run this way, the TCP socket will listen on `0.0.0.0`.

# License

MIT.

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