You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/logs/logs-context/configure-logs-context-nodejs.mdx
-85Lines changed: 0 additions & 85 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,8 +113,6 @@ If you're not using a supported framework, you may instead use the agent's log f
113
113
114
114
This option should not be used with in-agent forwarding. Using an [external log forwarder](/docs/logs/forward-logs/enable-log-management-new-relic#log-forwarding) to send logs to New Relic while in-agent forwarding is enabled will cause your logs to be sent up twice to New Relic. Depending on your account, this may result in double billing.
115
115
116
-
This option should also not be used with [the manual log decorating formatter](#3-old-formatter). If you have references to the manual formatter in your codebase, please remove them before enabling this option.
117
-
118
116
1. If you want to use this option, make sure you have the in-agent forwarding configuration option disabled.
119
117
120
118
newrelic.js:
@@ -159,19 +157,6 @@ If you're not using a supported framework, you may instead use the agent's log f
159
157
The output log message will be an empty string.
160
158
161
159
Some attributes may be empty if the log occurred outside a transaction or if they are not applicable to your application's context.
162
-
163
-
We recommend this option over manually using one of our log enrichers.
164
-
</Collapser>
165
-
166
-
<Collapser
167
-
id="3-old-formatter"
168
-
title="Option 3: Use the manual process to forward and decorate logs."
169
-
>
170
-
Before language agents had the ability to forward and decorate logs, you could enable logs in context by updating your application to use a framework-specific log enricher. This option is still supported, but is no longer encouraged. For instructions to use this approach, see [Manual logs in context option](#configure-nodejs).
171
-
172
-
Also, this method requires that you install a log forwarder before enabling logs in context. If you do not have a log forwarder, the New Relic UI will prompt you to use our [infrastructure agent](/docs/logs/forward-logs/forward-your-logs-using-infrastructure-agent/).
173
-
174
-
If you decide to use your existing log forwarding solution and later decide to update your agent to use automatic logs in context, be sure to <DNT>**disable your manual log forwarder**</DNT>. Otherwise, your app will be sending double log lines. Depending on your account, this could result in double billing. For more information, follow the procedures to disable your [specific log forwarder](/docs/logs/forward-logs/enable-log-management-new-relic#log-forwarding).
175
160
</Collapser>
176
161
</CollapserGroup>
177
162
@@ -204,76 +189,6 @@ If you don't see any logs for errors or traces, there may not be any for your ap
204
189
205
190
APM logs in context automatically forwards APM agent log data. It is enabled by default. If you do enable application logging, it can have a negative impact on your security, compliance, billing, or system performance. For more information, or if you need to adjust the default setting, follow the procedures to [disable automatic logging](/docs/logs/logs-context/disable-automatic-logging).
206
191
207
-
## Manual logs in context option [#configure-nodejs]
208
-
209
-
To enable logs in context for <InlinePopovertype="apm"/> apps monitored by Node.js, you can use our manual installation option.
210
-
211
-
1. Make sure you have already [set up logging in New Relic](/docs/logs/enable-log-management-new-relic/enable-log-monitoring-new-relic/enable-log-management-new-relic/). This includes configuring a supported log forwarder that collects your application logs and extends the metadata that is forwarded to New Relic.
212
-
213
-
2.[Install](/docs/agents/nodejs-agent/installation-configuration/update-nodejs-agent/) or [update](/docs/agents/nodejs-agent/installation-configuration/update-nodejs-agent/) to the latest Node.js agent version, and [enable distributed tracing](/docs/distributed-tracing/enable-configure/quick-start/). Use [Node.js agent version 6.2.0 or higher](/docs/release-notes/agent-release-notes/nodejs-release-notes/) for logs in context.
214
-
215
-
3. Install [a supported framework](#automatic) to enrich your log data, or directly use [the agent's log forwarding API](https://newrelic.github.io/node-newrelic/API.html#recordLogEvent).
216
-
217
-
4. In your agent configuration, set `application_logging.enabled` to `false`. (Otherwise, the agent will automatically instrument your logger and calling these enrichers yourself will do nothing.)
218
-
219
-
5. Configure logs in context for Node.js using the appropriate log extension.
220
-
221
-
<CollapserGroup>
222
-
<Collapser
223
-
id="nodejs-winston"
224
-
title="Node.js configuration with Winston"
225
-
>
226
-
1. To install the Winston log enricher, enter the following command into your terminal or command line interface:
227
-
228
-
```bash
229
-
npm install @newrelic/winston-enricher
230
-
```
231
-
2. In your application code, update your logging configuration to add the `newrelicFormatter`:
The New Relic formatter can be used individually or combined with other formatters as the final format.
241
-
242
-
```js
243
-
format:winston.format.combine(
244
-
winston.format.label({label:'test'}),
245
-
newrelicFormatter()
246
-
)
247
-
```
248
-
</Collapser>
249
-
250
-
<Collapser
251
-
id="nodejs-pino"
252
-
title="Node.js configuration with Pino"
253
-
>
254
-
1. To install the Pino log enricher, enter the following command into your terminal or command line interface:
255
-
256
-
```bash
257
-
npm install @newrelic/pino-enricher
258
-
```
259
-
2. In your application code, update your logging configuration to add the New Relic Pino plugin:
260
-
261
-
```js
262
-
// index.js
263
-
require('newrelic')
264
-
constnrPino=require('@newrelic/pino-enricher')
265
-
constpino=require('pino')
266
-
constlogger=pino(nrPino())
267
-
```
268
-
269
-
The New Relic formatter can be used individually or combined with other formatters as the final format.
270
-
</Collapser>
271
-
</CollapserGroup>
272
-
273
-
6. To verify that you have configured the log appender correctly, run your application, then check your [logs data in New Relic](/docs/logs/log-management/ui-data/use-logs-ui/) using the query operator `has:span.id has:trace.id`.
274
-
275
-
If everything is configured correctly and your data is being forwarded to New Relic with the enriched metadata, your logs should now be emitted as JSON and contain `trace.id` and `span.id` fields. If you don't see log data in the UI, follow the [troubleshooting procedures](/docs/logs/log-management/troubleshooting/no-log-data-appears-ui/). If you'd like to see a working example of logs in context, take a look at our [example application](https://github.com/newrelic/newrelic-node-examples/blob/main/logs-in-context/README.md).
276
-
277
192
## What's next? [#what-next]
278
193
279
194
After you set up <InlinePopovertype="apm"/> logs in context, make the most of your logging data:
0 commit comments