Enabling NGINX debug logs on the Routers

You're viewing Apigee Edge documentation.
Go to the Apigee X documentation.
info

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, on the Northbound (between the Client application and Router).

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.
  • 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.

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 ORG_NAME_ENV_NAME_VIRTUALHOST.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:

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 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.

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 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.