Mule 4 connectors debug logging

mule 4 connectors debug logging

How to Enable Logging for the different connectors in Mule 4 applications in anypoint studio and cloudhub

The following configuration is used to enable verbose logging for debugging purpose. Some important points to note when enabling verbose logging

  • The application performance is impacted when enabling verbose logging as it has to log each and every thing associated with the particular connector enabled for logging.
  • Debug/verbose logging should be done only temporarily and only for the duration of troubleshooting.
  • All logging will be done in plain text so be aware of any sensitive information being logged in cloudhub or logged to external services.
  • Be aware that verbose logging consumes lots of space and the cloudhub is limited to 100mb per application per instance (depending on license agreement). If the logging is done only in cloudhub then logs might be lost due to space constraint.
  • Verbose logging also leads to high CPU utilization, frequent application restart and unstable behavior and precicely for this reason debug or verbose logging should only be part of testing and troubleshooting.

Here is a curated list of all the configuration needed to enable verbose/debug logging for connectors/modules in anypoint studio and cloudhub.

All these configuration should be configured in log4j2.xml file which is located in the folder “src/main/resources

Verbose logging exception #

Anypoint Studio:

By default the stack trace will be shown with truncated output. Inorder to override this default configuration, use the following configuration option in local anypoint studio.

Right click on the Project Root in Studio, select “Run As” -> “Run Configuration” -> “Argument” tab, append the arguments in the VM arguments window, and add


-Dmule.verbose.exceptions=true
 
For example:  -XX:PermSize=128M -XX:MaxPermSize=256M -Dmule.verbose.exceptions=true

Cloudhub:

Add as Properties in the Deployment -> Settings -> Properties section


mule.verbose.exceptions=true

NOTE: This will restart the application, if it’s running, with zero downtime.

Maven:

Incase if you want to configure as a maven settings when deploying to cloudhub then use the following

<configuration> 
	... 
	<properties> 
		<mule.verbose.exceptions>true</mule.verbose.exceptions> 
	</properties>
	...
<configuration>

SSL DEBUG #

SSL debugging is used to troubleshoot handshake and certificate issues.

Anypoint Studio:

To configure the logging for SSL debugging, add the VM argument in Run Configurations by traversing Menu: Run —> Run Configurations. Switch to VM Arguments Tab, and add


-M-Djavax.net.debug=ssl

Cloudhub:

Add as Properties in the Deployment -> Settings -> Properties section


javax.net.debug=ssl

cloudhub-ssl-debugging-logging

HTTP connectors (listener and requester) #

Anypoint Studio:

To configure the logging for HTTP connectors in Anypoint Studio, use the following configuration in your log4j2.xml of your project. This configuration can be used in mule runtime 4.0 and above.

<Loggers>
    ...
    <AsyncLogger name="org.mule.service.http.impl.service.HttpMessageLogger" level="DEBUG" />
    ...
</Loggers>

This configuration will log all the HTTP listener and HTTP requester details. If its only necessary to log either HTTP listener or HTTP requester, it is possible in mule runtime 4.1.4 and above by adding the connector name after the logger name using dot notation.

Mule runtime 4.1.4 and above:

Anypoint Studio: These are the connector configuration names

<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config">
<http:request-config name="HTTP_Request_client" doc:name="HTTP Request configuration">

log4j2.xml:

<AsyncLogger name="org.mule.service.http.impl.service.HttpMessageLogger.HTTP_Listener_config" level="DEBUG" />
<AsyncLogger name="org.mule.service.http.impl.service.HttpMessageLogger.http.requester.HTTP_Request_client" level="DEBUG" />

Cloudhub:

Add the following configurations to the Settings page of the application under the Logging tab:

DEBUG   org.mule.service.http.impl.service.HttpMessageLogger

Mule runtime 4.1.4 and above only.

DEBUG	org.mule.service.http.impl.service.HttpMessageLogger.HTTP_Listener_config
DEBUG	org.mule.service.http.impl.service.HttpMessageLogger.http.requester.HTTP_Request_client

Salesforce Connector #

Anypoint Studio:

To configure the logging for Salesforce connectors in Anypoint Studio, use the following configuration in your log4j2.xml file of your project.

<Loggers>
    ...
    <AsyncLogger name="org.mule.extension.salesforce" level="DEBUG" />
    ...
</Loggers>

Cloudhub:

Add the following configurations to the Settings page of the application under the Logging tab:

DEBUG   org.mule.extension.salesforce

FTP Connector #

Anypoint Studio:

To configure the logging for FTP connectors in Anypoint Studio, use the following configuration in your log4j2.xml of your project.

<Loggers>
    ...
    <AsyncLogger name="org.mule.extension.ftp" level="DEBUG"/>
    ...
</Loggers>

Cloudhub:

Add the following configurations to the Settings page of the application under the Logging tab:

DEBUG   org.mule.extension.ftp

SFTP Connector #

Anypoint Studio:

To configure the logging for SFTP connectors in Anypoint Studio, use the following configuration in your log4j2.xml of your project.

<Loggers>
    ...
    <AsyncLogger name="org.mule.extension.sftp" level="DEBUG"/>
	<AsyncLogger name="com.jcraft" level="DEBUG"/>
    ...
</Loggers>

Cloudhub:

Add the following configurations to the Settings page of the application under the Logging tab:

DEBUG   org.mule.extension.sftp
DEBUG   com.jcraft

FTPS Connector #

Anypoint Studio:

To configure the logging for FTPS connectors in Anypoint Studio, use the following configuration in your log4j2.xml of your project.

<Loggers>
    ...
    <AsyncLogger name="com.mulesoft.extension.ftps" level="DEBUG"/>
    ...
</Loggers>

Cloudhub:

Add the following configurations to the Settings page of the application under the Logging tab:

DEBUG   com.mulesoft.extension.ftps

Amazon SQS Connector #

Anypoint Studio:

To configure the logging for Amazon SQS connectors in Anypoint Studio, use the following configuration in your log4j2.xml of your project.

<Loggers>
    ...
    <AsyncLogger name="org.mule.extension.sqs" level="DEBUG" />
	<AsyncLogger name="org.apache.http" level="DEBUG" />
    ...
</Loggers>

Cloudhub:

Add the following configurations to the Settings page of the application under the Logging tab:

DEBUG   org.mule.extension.sqs
DEBUG   org.apache.http

MuleSoft SAP connector #

Anypoint Studio:

To configure the logging for SAP connectors in Anypoint Studio, use the following configuration in your log4j2.xml of your project.

<Loggers>
    ...
    <AsyncLogger name="org.mule.modules.sap" level="DEBUG"/>
    ...
</Loggers>

For communications trace set the following Java startup environment properties:

-Djco.trace_level=N (N from 0 to 10).

10 being the highest level of trace. This should be added as a Java startup environment property.

Cloudhub:

Add as Properties in the Deployment -> Settings -> Properties section


jco.trace_level=N (N from 0 to 10).

NOTE: This will restart the application, if it’s running, with zero downtime.

Anypoint MQ #

Anypoint Studio:

To configure the logging for Anypoint MQ connectors in Anypoint Studio, use the following configuration in your log4j2.xml of your project.

<Loggers>
    ...
    <AsyncLogger name="com.mulesoft.extension.mq" level="DEBUG" />
    <AsyncLogger name="com.mulesoft.mq" level="DEBUG" />
    ...
</Loggers>

Cloudhub:

Add the following configurations to the Settings page of the application under the Logging tab:

DEBUG   com.mulesoft.extension.mq
DEBUG   com.mulesoft.mq

anypoint-mq-cloudhub-debug-logging

Database module #

Anypoint Studio:

To configure the logging for Anypoint MQ connectors in Anypoint Studio, use the following configuration in your log4j2.xml of your project.

<Loggers>
    ...
    <AsyncLogger name="org.mule.extension.db" level="DEBUG" />
    ...
</Loggers>

Cloudhub:

Add the following configurations to the Settings page of the application under the Logging tab:

DEBUG org.mule.extension.db

Mule Batch Debug Logging #

Anypoint Studio:

To configure the logging for Anypoint MQ connectors in Anypoint Studio, use the following configuration in your log4j2.xml of your project.

<Loggers>
    ...
    <AsyncLogger name="com.mulesoft.module.batch" level="DEBUG" />
    ...
</Loggers>

Cloudhub:

Add the following configurations to the Settings page of the application under the Logging tab:

DEBUG com.mulesoft.module.batch

Other connectors #

Anypoint Studio:

Check the connector java packages on the package explored in anypoint studio and configure

<Loggers>
    ...
    <AsyncLogger name="<package>" level="DEBUG"/>
    ...
</Loggers>

503 Service Unavailable - Gatekeeper #

While testing locally (example using postman) the API might returns 503 Service Unavailable error to clients. This is due to Gatekeeper which by default blocks any incoming request to the API if the API has not been successfully paired with API Manager to receive appropriate policies.

To overcome this issue select

“Run As” -> “Run Configuration” -> “Argument” tab, append the arguments in the VM arguments window, and add

-Danypoint.platform.gatekeeper=disabled