Configuring Message Logging for Flex Gateway in Connected Mode | MuleSoft Documentation
# Configuring Message Logging for Flex Gateway in Connected Mode
Applying a Message Logging policy to your API instance in API Manager allows you to view basic logs, such as inbound and outbound calls and headers, for APIs managed by Flex Gateway within API Manager. Logging for an API instance only happens if you configure and apply a Message Logging policy.
To view metrics in API Manager, such as total requests, total policy violations, total errors, and average response time, see Viewing Key Metrics in API Manager for Flex Gateway in Connected Mode.
## Message Logging Limits and Features
API Manager stores up to 100 MB of logs per API instance for 30 days. Runtime Manager automatically purges logs that go beyond 100 MB per API instance. If you need more storage, you can either use a third-party service (configured through a policy) or sign up for the Anypoint Integration Advanced package or a Titanium subscription to Anypoint Platform.
Basic logs report this information for each API instance configured through a policy:
  * Inbound and outbound API calls, as well as the packet contents
  * Headers and any other information in the request


To view message logs in API Manager, you need one of the following permissions:
  * API Manager Environment Administrator
  * API Manager Deploy API Proxies
  * General Organization Administration


Refer to Permissions Available in Anypoint Platform.
## Configure Message Logging in Connected Mode
  1. From API Administration in API Manager, select the name of the API Instance.
  2. Click **Policies**.
  3. Click **+ Add policy**.
  4. Click **Message Logging** in the **Troubleshooting** category.
  5. Click **Next**.
  6. Click **+ Add**.
  7. Enter a **Configuration Name** , for example, 'Info messages before calling API'.
  8. Enter a DataWeave expression that selects what information you want to see.
For example, `#[attributes.headers['id']]` extracts the ids from the headers of the messages. For more information, see DataWeave Support in Flex Gateway Policies.
  9. If you want to filter log messages, enter a DataWeave expression.
For example, `#[attributes.headers['id']==1]` shows log messages that have an id of 1 in the header.
  10. If you want to affix a prefix to your logs, enter a **Category**.
  11. Enter the severity level.
You can only enter one level. See Message Logging Severity Levels for a description of each severity level and the hierarchy for the levels.
  12. If you want messages after the API is called, select **After Calling API**.
  13. If you want to add additional configurations, click **+ Add**.
  14. Click **Save**.
Afterward, you should see a **Message Log** option for the API instance.
Use the search field to search for specific logs based on the time and log severity (INFO, ERROR, WARN, DEBUG). You can download these logs for further analysis.


## Message Logging Severity Levels
When you configure a Message Logging policy for your API instance, you can assign a severity level. Each severity level includes a specific set of information in the log report.
Log reports include the severity level you select and the following levels on the hierarchy.
For example, if you select DEBUG, the log reports include the DEBUG severity level as well as the INFO, WARN, and ERROR severity levels. However, if you select ERROR, the log reports include only error messages. The following table describes the type of information included in the logs for each severity level:
Log Severity Level | Description  
---|---  
Tracing information used by application developers.  
Informational messages that highlight the progress of the application.  
Potentially harmful situations that indicate potential problems.  
Events that prevent normal program execution but might allow the application to continue running.