You're viewing **Apigee Edge** documentation.  
[Go to the
**Apigee X** documentation](http://cloud.google.com/apigee/docs/hybrid/v1.8/logging). info

> [!NOTE]
> **Note:** The instructions in this document are applicable for Edge Private Cloud users only.


On Apigee, the Routers are configured to log only the error messages in the error log files by
default. However, there could be many situations where you may need to gather more information to
determine why a specific error occurred. One of the ways to do this is to configure the Router to
operate in debug mode so that you can get debug logs, which can help you to gain more information
about the error and resolve it faster.


This document explains how to enable debug logs on the Apigee Edge's Router for the requests on a
specific virtual host. Debug logging can be enabled to capture more information when there are any
issues such as malformed request,
[400 Bad Request - SSL Certificate Error](https://docs.apigee.com/api-platform/troubleshoot/runtime/400-ssl-certificate-error), on the
[Northbound](https://docs.apigee.com/api-platform/system-administration/about-ssl#northandsouthbound)
(between the Client application and Router).

> [!NOTE]
> **Note:** It is recommended to have the default configuration that is to log only the error messages for NGINX to avoid any performance implications. However, if you need to gather additional debug information to debug a specific issue, then ensure that you are enabling the NGINX debug log on the Router ***for only a short period of time***. Once you have gathered the required information, immediately revert back to the normal mode.

## Before you begin

- If you aren't familiar with the NGINX error logs and levels of logging, please refer to the [NGINX error log documentation](http://nginx.org/en/docs/ngx_core_module.html#error_log).
- Gather the organization, environment and virtual host names of the API requests for which you need to collect debug information.

## Enabling NGINX debug logs on the Routers


This section explains how to enable debug logs on the Edge Routers.

> [!TIP]
> **Required permissions:** To perform this task, you must have the following permissions:
>
> - Access to the specific Routers, where you would like to enable debug logs.
> - Access to edit the Router component virtual host conf files in the `/opt/nginx/conf.d/ `folder.

### Identifying relevant virtual host configurations file


The following steps describe how to locate the relevant virtual host configuration file on the Router:

1. If you know the organization name, environment name and virtual host for the specific API request which you would like to debug, then determine the virtual host conf file as follows:
   1. Navigate to the `/opt/nginx/conf.d/` directory.
   2. Search for file <var translate="no">ORG_NAME</var>_<var translate="no">ENV_NAME</var>_<var translate="no">VIRTUALHOST</var>`.conf` file in the `conf.d` directory using the following command:

      ```
      ls -ltrh | grep "ORG_NAME_ENV_NAME_VIRTUALHOST_NAME"
      ```
2.
   If you don't know the organization name, you can identify the virtual host configuration
   file by using the host alias name that is used in the API request as follows:


   Navigate to the `/opt/nginx/conf.d/` directory and search for
   `hostalias` with which the request was made using the following command:

   ```
   ls -ltrh | grep -r 'HOST_ALIAS_NAME'
   ```

   **Sample output:**


   Let's say the host alias name is `opdk.cert-test.com`. When you run the
   `ls -ltrh` command, then you will see the output as shown below:


   ![](https://docs.apigee.com/static/images/ht-nginx-debug-log-ls-sample-output.png)
   **Note**: Multiple configuration files will be shown in case of using the same host alias on different ports. Identify the port number on which API requests have been made to identify the corresponding virtual host configuration file.

### Enabling debug logging for a specific virtual host on the Router


The following steps describe how to enable debug logs on the Apigee Routers for a specific
virtual host.

1. Open the following file on the Router machine in an editor: `/opt/nginx/conf.d/ORG_NAME_ENV_NAME_VIRTUALHOST_NAME.conf`. For example:

   ```
   vi /opt/nginx/conf.d/ORG_NAME_ENV_NAME_VIRTUALHOST_NAME.conf
   ```
2. Change the following line:

   ```
   error_log /opt/apigee/var/log/edge-router/nginx/ORG_NAME~ENV_NAME.PORT_error_log error;
   ```


   to

   ```
   error_log /opt/apigee/var/log/edge-router/nginx/ORG_NAME~ENV_NAME.PORT_error_log info;
   ```
3. Save your changes.
4. Run the NGINX reload command. For example:

   ```
   sudo /opt/nginx/scripts/apigee-nginx reload
   ```
5. The following file will now capture **debug** logs:

   ```
   /opt/apigee/var/log/edge-router/nginx/ORG_NAME~ENV_NAME.PORT_error_log
   ```
6. If you want to capture debug logs on more than one Router, repeat these steps on each of the Routers.

## Verifying debug information is logged in NGINX error log file

1.
   Once clients make API Requests on the host alias and port associated with the virtual host
   configuration, debug logs will be captured in the following file:


   `/opt/apigee/var/log/edge-router/nginx/ORG_NAME~ENV_NAME.PORT_error_log `
2.
   Verify that you are seeing debug information for the API requests as shown in the following example:

   **Sample debug information:**

   ```
   2021/01/27 02:48:40 [warn] 27624#27624: *3777 a client request body is buffered to a temporary file /opt/apigee/var/log/edge-router/nginx/client_temp/0000000001, client: XX.XX.XX.XX, server: XX.XX.XX.XX, request: "POST /post-no-target HTTP/1.1", host: "XX.XX.XX.XX:443"
   ```


   The information shown above will be captured when the client sends a `POST` request with
   a large payload. This log will be shown only when debug logging is enabled.
3. If you don't see additional debug information, then verify that you have followed all the steps outlined in [Enabling debug logging for a specific virtual host on the Router](https://docs.apigee.com/api-platform/troubleshoot/debugging/enable-nginx-debug-logs-on-routers#enable-logging-specific-host) correctly. If you have missed any step, repeat all the steps again correctly.
4. If you are still not able to get the debug information, then please contact [Apigee Edge Support](https://docs.apigee.com/api-platform/troubleshoot/support).

## Disabling debug logs for a specific virtual host on the Router


This section explains how to disable the debug logs at Router for a specific virtual host.

1. Open the following file on the Router machine in an editor: `/opt/nginx/conf.d/ORG_NAME_ENV_NAME_VIRTUALHOST_NAME.conf` For example:

   ```
   vi /opt/nginx/conf.d/ORG_NAME_ENV_NAME_VIRTUALHOST_NAME.conf
   ```
2.
   Change the following line:

   ```
   error_log /opt/apigee/var/log/edge-router/nginx/ORG_NAME~ENV_NAME.PORT_error_log info;
   ```


   to

   ```
   error_log /opt/apigee/var/log/edge-router/nginx/ORG_NAME~ENV_NAME.PORT_error_log error;
   ```
3. Save your changes.
4. Run the NGINX reload command. For example:

   ```
   /opt/nginx/scripts/apigee-nginx reload
   ```
5. The following file will now capture only **error** logs:

   ```
   /opt/apigee/var/log/edge-router/nginx/ORG_NAME~ENV_NAME.PORT_error_log
   ```
6. If you want to stop debug logs on more than one Router, repeat these steps on each of the Routers.

## Verifying only error information is logged in NGINX error log file

1. Make some API requests on the host alias and port associated with the specific virtual host configuration or wait for the clients to make the requests.
2. Check the following file: `/opt/apigee/var/log/edge-router/nginx/ORG_NAME~ENV_NAME.PORT_error_log `
3. Verify that you are seeing only the error information and debug information is no longer logged for the requests.
4. If you still see additional debug information is being logged, then verify that you have followed all the steps outlined in [Disabling debug logs for a specific virtual host on the Router](https://docs.apigee.com/api-platform/troubleshoot/debugging/enable-nginx-debug-logs-on-routers#disable-debug-logs-specific-host) correctly. If you have missed any step, repeat all the steps again correctly.
5. If you are still not able to get the debug information, then please contact [Apigee Edge Support](https://docs.apigee.com/api-platform/troubleshoot/support).