Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move node recommended setup to @fluent-org/logger #357

Merged
merged 1 commit into from
Aug 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions language-bindings/nodejs.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Nodejs

The [`fluent-logger-node`](https://github.com/fluent/fluent-logger-node) library is used to post records from Node.js applications to Fluentd.
The [`@fluent-org/logger`](https://github.com/fluent/fluent-logger-forward-node) library is used to post records from Node.js applications to Fluentd.

This article explains how to use it.
jamiees2 marked this conversation as resolved.
Show resolved Hide resolved

NOTE: The previous NPM package, [`fluent-logger`](https://github.com/fluent/fluent-logger-node) has been deprecated in favor of `@fluent-org/logger`.

## Prerequisites

* Basic knowledge of Node.js and NPM
* Basic knowledge of Fluentd
* Node.js 6.0 or higher
* Node.js 12.0 or higher

## Installing Fluentd

Expand Down Expand Up @@ -43,15 +45,15 @@ $ sudo /etc/init.d/td-agent restart
$ sudo systemctl restart td-agent.service
```

## Using `fluent-logger-node`
## Using `@fluent-org/logger`

### Obtaining the Most Recent Version

The most recent version of `fluent-logger-node` can be found [here](https://www.npmjs.com/package/fluent-logger).
The most recent version of `@fluent-org/logger` can be found [here](https://www.npmjs.com/package/@fluent-org/logger).

### A Sample Application

Here is a sample [Express](http://expressjs.com/) app using `fluent-logger-node`:
Here is a sample [Express](http://expressjs.com/) app using `@fluent-org/logger`:

#### `package.json`

Expand All @@ -61,7 +63,7 @@ Here is a sample [Express](http://expressjs.com/) app using `fluent-logger-node`
"version": "0.0.1",
"dependencies": {
"express": "^4.16.0",
"fluent-logger": "^3.2.0"
"@fluent-org/logger": "^1.0.2"
}
}
```
Expand All @@ -78,15 +80,16 @@ This is a simple web app:

```text
const express = require('express');
const logger = require('fluent-logger');
const FluentClient = require('@fluent-org/logger').FluentClient;
const app = express();

// The 2nd argument can be omitted. Here is a default value for options.
logger.configure('fluentd.test', {
host: 'localhost',
port: 24224,
timeout: 3.0,
reconnectInterval: 600000 // 10 minutes
const logger = new FluentClient('fluentd.test', {
socket: {
host: 'localhost',
port: 24224,
timeout: 3000, // 3 seconds
}
});

app.get('/', function(request, response) {
Expand Down