Skip to content
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
13 changes: 7 additions & 6 deletions content/en/logs/log_collection/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

## Configure your logger

To send your logs to Datadog, log to a file and [tail][14] that file with your Datadog Agent. Use the [Winston][1] logging library to log from your Node.js application.
To send your logs to Datadog, log to a file and [tail][14] that file with your Datadog Agent. Use a logging library, such as [Winston][1], [Bunyan][15], or [Pino][16], to log from your Node.js application. The examples on this page use Winston.

Winston is available through [NPM][2], to get started, you want to add the dependency to your code:
Winston is available through [NPM][2]. To get started, add the dependency to your code:

Check warning on line 31 in content/en/logs/log_collection/nodejs.md

View workflow job for this annotation

GitHub Actions / vale

Datadog.words_case_sensitive

Use 'CNM' instead of 'NPM'.

```text
npm install --save winston
Expand Down Expand Up @@ -110,7 +110,7 @@

## Configure your Datadog Agent

Once [log collection is enabled][6], set up [custom log collection][7] to tail your log files and send new logs to Datadog.
After [log collection is enabled][6], set up [custom log collection][7] to tail your log files and send new logs to Datadog.

1. Create a `nodejs.d/` folder in the `conf.d/` [Agent configuration directory][8].
2. Create a `conf.yaml` file in `nodejs.d/` with the following content:
Expand All @@ -137,14 +137,13 @@

## Connect your service across logs and traces

If APM is enabled for this application, connect your logs and traces by automatically adding trace IDs, span IDs,
`env`, `service`, and `version` to your logs by [following the APM Node.js instructions][3].
If APM is enabled for this application, connect your logs and traces by [following the APM Node.js instructions][3]. This automatically adds trace IDs, span IDs, `env`, `service`, and `version` to your logs.

**Note**: If the Datadog SDK injects `service` into your logs, it overrides the value set in the Agent configuration.

## Agentless logging

You can stream your logs from your application to Datadog without installing an Agent on your host. However, it is recommended that you use an Agent to forward your logs as it provides a native connection management.
You can stream your logs from your application to Datadog without installing an Agent on your host. However, Datadog recommends you use an Agent to forward your logs as it provides a native connection management.

Use the [Winston HTTP transport][4] to send your logs directly through the [Datadog Log API][5].
In your bootstrap file or in your code, declare the logger in the following way:
Expand Down Expand Up @@ -208,3 +207,5 @@
[12]: /logs/explorer/#overview
[13]: https://github.com/winstonjs/winston/blob/master/docs/transports.md#datadog-transport
[14]: /glossary/#tail
[15]: https://github.com/trentm/node-bunyan
[16]: https://getpino.io/
Loading