# node-red-contrib-logger-vh

> Node-RED node to log to the debug window, the console, a file or to the ELK stack

Latest version **1.3.2** (published 2025-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-red-contrib-logger-vh
pnpm add node-red-contrib-logger-vh
yarn add node-red-contrib-logger-vh
bun add node-red-contrib-logger-vh
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.2 |
| Published | 2025-08-28 |
| First published | 2023-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 274.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Van Hoecke NV |
| Maintainers | vhict |
| Keywords | node-red, logging, elastic, elasticsearch, elk |

## Links

- npm: https://www.npmjs.com/package/node-red-contrib-logger-vh
- npm.io page: https://npm.io/package/node-red-contrib-logger-vh

## Dependencies (6)

- [axios](https://npm.io/package/axios.md) ^1.6.2
- [winston](https://npm.io/package/winston.md) ^3.8.2
- [axios-retry](https://npm.io/package/axios-retry.md) ^3.9.1
- [winston-transport](https://npm.io/package/winston-transport.md) ^4.6.0
- [safe-json-stringify](https://npm.io/package/safe-json-stringify.md) ^1.2.0
- [winston-elasticsearch](https://npm.io/package/winston-elasticsearch.md) ^0.17.1

## 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

- 1.3.2 (latest) — 2025-08-28
- 1.3.1 — 2024-06-14
- 1.3.0 — 2024-06-13
- 1.2.2 — 2024-06-11
- 1.2.1 — 2024-06-11
- 1.2.0 — 2023-12-18
- 1.1.0 — 2023-10-09
- 1.0.6 — 2023-01-19
- 1.0.5 — 2023-01-19
- 1.0.4 — 2023-01-19
- 1.0.3 — 2023-01-19
- 1.0.2 — 2023-01-18
- 1.0.1 — 2023-01-09

## README

# node-red-contrib-logger-vh

A module for Node-RED that allows you to log to the following outputs:

- ELK stack (ElasticSearch & Logstash) via HTTP
- Files
- System Console
- Debug window

The `winston` and `winston-logging` libraries are used for this.

This project is based on [node-red-contrib-advanced-logger](https://www.npmjs.com/package/node-red-contrib-advanced-logger) and [node-red-contrib-log-elk](https://flows.nodered.org/node/node-red-contrib-log-elk).

# Installation

Run the following command in your Node-RED directory:

```console
npm i node-red-contrib-logger-vh
```

This command can also be embedded in a Dockerfile, alongside any other NPM package installations.

# Features

Four outputs are supported, which are all discussed below. The log message itself can be a `string` a `JSON` object or the entire `msg` object. In each log message, several fields and meta data can be added next to the message to log itself:

| Field       | Variable                    | Default             | Detail                                                                                                                             |
| ----------- | --------------------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| LogLevels   | `msg.logLever` or manual    | "debug"             | Four log levels are supported: `debug`, `info`, `warning` and `error`                                                              |
| Group       | `msg.group` or manual       | /                   | The name of the group in Node-RED in which the log node is located (e.g. standard `.env`-variable from Node-RED: `NR_GROUP_NAME`). |
| Flow        | `msg.flow` or manual        | /                   | The name of the flow in which the log node is located (e.g. standard `.env`-variable `NR_FLOW_NAME`).                              |
| Key         | `msg.key` or manual         | /                   | A free string field in which you can place specific information to link different messages to each other (e.g. "customerId: 123"). |
| Trace ID    | `msg.traceId` or manual     | /                   | A field to store a unique trace ID if required                                                                                     |
| Application | `msg.application` or manual | "node-red instance" | The name of the application.                                                                                                       |
| server      | `msg.server`                | `os.hostname()`     | The name of the server. By default, the name is retrieved by using `os.hostname()`, but this will not work when running in Docker. |
| User        | `msg.user`                  | "node-red user"     | The name of the (service) account that runs the application.                                                                       |
| ProcessId   | `process.pid()`             | /                   | The process ID is filled in automatically and can be helpful when many parallel processes are running.                             |

## ELK Stack

You can log directly to Elastic. For this, you can:

- Define an arbitrary index name
- Set up the data to be sent as a data stream
- Log via Logstash
- Add username and password for basic authentication

### Log via Logstash

If you choose to log to Logstash instead of logging to Elastic directly, you need to check the 'Logstash' option in the configuration node. The index name is appended to the URL, just as you would normally log to Elastic. You don't need to use this, but if requested, you can filter the index name from the URL in a Logstash pipeline. An example of a `.conf` file could be:

```conf
input {
  http {
    port => 5000
    codec => "json"
  }
}

filter {
  if ![url][path] or [url][path] == "/" {
    mutate {
      add_field => { "index" => "logs" }
    }
  } else {
    grok {
      match => { "[url][path]" => "/(?<index>.*)" }
    }
  }
}

output {
  elasticsearch {
    hosts => ["${ELASTIC_HOSTS}"]
    user => "${ELASTIC_USER}"
    password => "${ELASTIC_PASSWORD}"
    index => "%{index}"
    action => "create"
  }
}
```

Here, the name of the index is taken from the URL or defaulted to 'logs'. For example:

```
POST http://logstash:5000/node-red-logs
```

This will log to the 'node-red-logs' index in Elastic. If not required, you can leave out the 'filter' section and just fill in the 'index' manually.

## Files

- Choose file name
- Set maximum size
- Set maximum number of log files

# Examples

See the `examples` directory.

![logger](examples/example-flow.PNG "logger")

# Testing

The unit tests use the [Mocha framework](https://mochajs.org/).

To run the tests, execute the following command:

```console
$ npm run test
```

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