---
title: Node.js agent logging settings
source: https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration-logging-settings
---

This page covers the Node.js agent settings for controlling agent log output and audit logging of collector payloads.

> #### 💡 TIP
>
> Back to the full settings index: [Node.js agent configuration](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/installation-configuration/nodejs-agent-configuration)

## Logging variables [#logging_config]

This section defines the Node.js agent variables in the order they typically appear in the `logging: {` section of your app's `newrelic.js` configuration file.

**enabled**

| Type                             | String                                |
| -------------------------------- | ------------------------------------- |
| Default                          | `true` (`false` in `serverless_mode`) |
| [Environ variable](#environment) | `NEW_RELIC_LOG_ENABLED`               |

Enables or disables agent specific logging.

**level**

| Type                             | String                |
| -------------------------------- | --------------------- |
| Default                          | `info`                |
| [Environ variable](#environment) | `NEW_RELIC_LOG_LEVEL` |

Defines the level of detail recorded in the agent logs. From least detail to most detail, possible values are `fatal`, `error`, `warn`, `info`, `debug`, or `trace`.

> #### ⚠️ CAUTION
>
> Do not use `debug` or `trace` logging unless New Relic Support asks you to use them. These levels of logging can generate excessive overhead. For most situations, use `info`.

**filepath**

| Type                             | String                                    |
| -------------------------------- | ----------------------------------------- |
| Default                          | `process.cwd()` plus `newrelic_agent.log` |
| [Environ variable](#environment) | `NEW_RELIC_LOG`                           |

Complete path to the New Relic agent log, including the filename. Defaults to `filepath: require('path').join(process.cwd(), 'newrelic_agent.log')`. If the agent can't create the log file, then it:

-   Logs the `New Relic failed to open log file` error using `console.error`.

-   Buffers all subsequent log messages in memory.

-   When the memory buffer reaches its 128 MiB limit, the agent discards any new log messages and emits the following warning via `process.emitWarning`: `[NRWARN001] NewRelicWarning: Dropping log message, buffer would overflow.`

    When creating the log file, the agent sets the file permissions to 0o600 (readable/writable to the owner).

-   To write all logging to **stdout**, set this to `stdout`.

-   To write all logging to **stderr**, set this to `stderr`.

    > #### ⚠️ IMPORTANT
    >
    > In agent versions prior to 7.0.0, the agent would shut down the process if it was unable to create this file.

## Audit logging [#audit_log]

This section defines the Node.js agent variables in the order they typically appear in the `audit_log: {` section of your app's `newrelic.js` configuration file.

**enabled**

| Type                             | Boolean                       |
| -------------------------------- | ----------------------------- |
| Default                          | `false`                       |
| [Environ variable](#environment) | `NEW_RELIC_AUDIT_LOG_ENABLED` |

When enabled, the agent logs the payloads it sends to the collector. This data is included in the main log file even when logging level is set to the lowest level.

**endpoints**

| Type                             | Array                           |
| -------------------------------- | ------------------------------- |
| Default                          | `[]` (include all types)        |
| [Environ variable](#environment) | `NEW_RELIC_AUDIT_LOG_ENDPOINTS` |

The agent sends several different types of data to the collector in separate payloads. By default, all of them are included in the log file. This option makes it possible to limit logging only to specific types of data.

Valid values include:

-   `agent_settings`
-   `analytic_event_data`
-   `connect`
-   `custom_event_data`
-   `error_data`
-   `error_event_data`
-   `metric_data`
-   `preconnect`
-   `shutdown`
-   `span_event_data`
-   `sql_trace_data`
-   `transaction_sample_data`
