Datadog Mule Integration 4 APM

Logging | Logs Forwarding

Logs forwarding in CloudHub

Configure the log4j2.xml file with the CloudHub appender.

<Appenders>
  <Log4J2CloudhubLogAppender name="CLOUDHUB"
        addressProvider="com.mulesoft.ch.logging.DefaultAggregatorAddressProvider"
        applicationContext="com.mulesoft.ch.logging.DefaultApplicationContext"
        appendRetryIntervalMs="${sys:logging.appendRetryInterval}"
        appendMaxAttempts="${sys:logging.appendMaxAttempts}"
        batchSendIntervalMs="${sys:logging.batchSendInterval}"
        batchMaxRecords="${sys:logging.batchMaxRecords}"
        memBufferMaxSize="${sys:logging.memBufferMaxSize}"
        journalMaxWriteBatchSize="${sys:logging.journalMaxBatchSize}"
        journalMaxFileSize="${sys:logging.journalMaxFileSize}"
        clientMaxPacketSize="${sys:logging.clientMaxPacketSize}"
        clientConnectTimeoutMs="${sys:logging.clientConnectTimeout}"
        clientSocketTimeoutMs="${sys:logging.clientSocketTimeout}"
        serverAddressPollIntervalMs="${sys:logging.serverAddressPollInterval}"
        serverHeartbeatSendIntervalMs="${sys:logging.serverHeartbeatSendIntervalMs}"
        statisticsPrintIntervalMs="${sys:logging.statisticsPrintIntervalMs}">
    
      <PatternLayout pattern="[%d{MM-dd HH:mm:ss}] %-5p %c{1} [%t]: %m%n"/>
  </Log4J2CloudhubLogAppender>
</Appenders>

When an application is deployed in CloudHub the Runtime Manager always overwrites the log4j2.xml Disable the CloudHub logs in order for Runtime Manager to apply the project’s log4j2.xml configuration file.

Disable the CloudHub logs UI

By default, Disable CloudHub logs is not a visible option in Runtime Manager. A special request to the Mulesoft support team is required to enable this option. More info: https://docs.mulesoft.com/runtime-manager/custom-log-appender

In order to deploy the app in CloudHub, add the ddkeyApi property. Because of security reasons, put in the mule-artifact.json ddApiKey as a secure property:

{
  "minMuleVersion": "4.3.0",
  "secureProperties": ["ddApiKey"]
}
Secure properties view in Runtime Manager

The logs shown in the live console are the logs generated by the log4j2.xml file.

Logs produced in CloudHub

The same event Id can be seen in the log forwarded to Datadog Log.

Log in Datadog Log

PREVIOUS TOPIC


< Logging