---
title: Generate logs for troubleshooting the infrastructure agent
source: https://docs.newrelic.com/docs/infrastructure/infrastructure-troubleshooting/troubleshoot-logs/generate-logs-troubleshooting-infrastructure
---

## Problem

When troubleshooting your infrastructure agent, generate `debug` logs for a few minutes to find and investigate errors. This can be useful for your own troubleshooting or when working with New Relic Support.

> #### ⚠️ IMPORTANT
>
> Verbose logging generates a lot of data very quickly. When finished generating logs, be sure to set `level: info` (or lower) to reduce disk space consumption and data ingest when forwarding logs to New Relic.

You can automate this process by using the `newrelic-infra-ctl` command. For more information, see the [troubleshooting binary documentation](https://docs.newrelic.com/docs/infrastructure/install-configure-manage-infrastructure/manage-your-agent/troubleshoot-running-agent).

## Solution

Generating `debug` log files requires editing your configuration file. For a sample config file that includes all applicable settings, see the [example template](https://docs.newrelic.com/docs/infrastructure/new-relic-infrastructure/configuration/infrastructure-config-file-template-newrelic-infrayml). To generate detailed logs:

| Step | Procedures                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| -    | Edit your `newrelic-infra.yml` file with logging settings: ````yml log:   level: debug   file: /path/to/logfile.log ```  1. Enable debug logging: [`level: debug`](/docs/infrastructure/new-relic-infrastructure/configuration/configure-infrastructure-agent#logging-variables). (If you use a containerized infrastructure agent on CoreOS, see [system-specific notes](#system-notes).) 2. Set [`file`](/docs/infrastructure/install-configure-infrastructure/configuration/infrastructure-configuration-settings#file) to a convenient log file location. 3. [Restart the agent](/docs/infrastructure/new-relic-infrastructure/configuration/start-stop-restart-check-infrastructure-agent-status) so the agent notices the new settings.  ```` |
| -    | Let your host run at normal load for about three minutes to generate sufficient logging data.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| -    | Return your settings to default: - Disable verbose logging by setting [`level: info`](https://docs.newrelic.com/docs/infrastructure/new-relic-infrastructure/configuration/configure-infrastructure-agent#level) in `newrelic-infra.yml`. - Optional: Disable logging to a custom file by removing the [`file`](https://docs.newrelic.com/docs/infrastructure/new-relic-infrastructure/configuration/configure-infrastructure-agent#file) line from the `log` section in `newrelic-infra.yml`. - [Restart the agent](https://docs.newrelic.com/docs/infrastructure/new-relic-infrastructure/configuration/start-stop-restart-check-infrastructure-agent-status) so the agent notices the new settings.                                              |
| -    | Examine the log file for errors. If you need to send your log file to New Relic Support: - Include the line in your log file that contains the agent version: ``` New Relic infrastructure agent version X.YY.ZZZ ``` - Attach the log file to your support ticket, along with your `newrelic-infra.yml`.                                                                                                                                                                                                                                                                                                                                                                                                                                           |

### Smart verbose mode

Sometimes errors don't occur until after quite some time has passed. This makes debugging difficult, because typically verbose logs are only enabled for a short period time; otherwise there will be many debug logs. For example, if an error occurs one hour after the infrastructure agent has started, getting debug logs around the time of the error can be tricky or impractical.

As of infrastructure agent v1.9.0 or higher, you can use smart verbose mode for logs. Smart verbose mode only logs the most recent debug messages after an error has been logged. This allows you to leave smart verbose mode running until an error occurs, without logging lots of irrelevant debug messages, and only logging the most recent debug messages. (The number of messages is determined by your configuration.)

For more information on smart verbose mode, see the [Infrastructure agent logging behavior](https://docs.newrelic.com/docs/infrastructure/infrastructure-troubleshooting/troubleshoot-logs/infrastructure-agent-logging-behavior#smart-verbose-mode) docs, and use the [Infrastructure configuration settings](https://docs.newrelic.com/docs/infrastructure/install-configure-manage-infrastructure/configuration/infrastructure-configuration-settings#verbose) documentation for details on how to enable smart verbose mode.

### Forward the agent logs to New Relic [#forward-logs-to-nr-logs]

The infrastructure agent can be configured to [send its own logs to New Relic](https://docs.newrelic.com/docs/logs/new-relic-logs/get-started/introduction-new-relic-logs). This can be useful for troubleshooting issues with log forwarding, the infrastructure agent, or when contacting support.

For details on how to enable log forwarding for the infrastructure agent, see [Troubleshoot log forwarding](https://docs.newrelic.com/docs/logs/enable-new-relic-logs/1-enable-logs/forward-your-logs-using-new-relic-infrastructure#troubleshoot).

### Notes for specific systems [#system-notes]

These are some additional notes and requirements for specific systems, used to supplement the [general logging instructions](#verbose):

**Containerized agent**

If you are using a containerized infrastructure agent:

1.  Choose one of these options to change the log level to verbose:

    -   Recommended: Set the environment variable `NRIA_LOG_LEVEL` to `debug`. Running this on the command line would look like:

        ```sh
        -e NRIA_LOG_LEVEL=debug
        ```

        OR
    -   Edit the config file to set `level: debug` in the `log` section. (Editing the config file in a container is not recommended, because it requires rebuilding the image twice: once to add verbose logging and once to remove it.)
2.  Use `journalctl` to collect the logs:

    ```sh
    journalctl -u newrelic-infra > newrelic-infra.log
    ```
3.  Set the logging level back to `info` or `warn` after collecting logs for a few minutes.
