Contact Free trial Login

Integrating with Your Logging System Using Log4j

logo cloud active logo hybrid disabled logo server disabled logo rtf disabled

You can disable CloudHub logs and integrate your CloudHub application with your logging system by using the Log4j configuration. After you configure logs to flow to both your log system and CloudHub, disable the default CloudHub application logs.

Requirements and Restrictions

  • This feature is available only on request.

    If you do not see the Disable CloudHub logs option in Runtime Manager, you can request it on the Support portal.

  • MuleSoft is not responsible for issues arising from misconfiguration of your Log4j appender, including these or other issues:

    • Lost logging data

    • Performance degradation

    • Running out of disk space

  • Do not use synchronous log appenders.

    You can use only asynchronous log appenders.

  • When you disable CloudHub logs:

    • Only the system logs are available in Runtime Manager.

      System logs provide the status of your worker deployment and whether your application started correctly, but do not provide application logs. For application worker logs, check the logging system for your application.

    • You cannot download application worker logs from the Applications > Logs page.

    • CloudHub warns you that logs are not available.

Create Your Log4j Configuration

For logs to both flow to your logging system and be viewable in CloudHub, configure the CloudHub Log4j appender. The Log4j appender sends log data to CloudHub and to a local log file.

To enable the Log4j appender, update the log4j2.xml configuration file with your logger settings. In Anypoint Studio, the log4j2.xml file is located in the src/main/resources directory.

For information about configuring log4j2.xml, see the Log4j documentation.

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO" name="cloudhub" packages="com.mulesoft.ch.logging.appender">
    <Appenders>
        <RollingFile name="FILE"
                     fileName="/opt/mule/mule-CURRENT/logs/mule-${sys:domain}.log"
                     filePattern="/opt/mule/mule-CURRENT/logs/mule-${sys:domain}-%i.log">

            <PatternLayout pattern="[%d{MM-dd HH:mm:ss.SSS}] %-5p %c{1} [%t]: %m%n"/>
            <DefaultRolloverStrategy max="10"/>
            <Policies>
                <SizeBasedTriggeringPolicy size="10 MB" />
            </Policies>
        </RollingFile>
        <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>
    <Loggers>
        <AsyncRoot level="INFO">
            <AppenderRef ref="FILE"/>
            <AppenderRef ref="CLOUDHUB"/>
        </AsyncRoot>
        <AsyncLogger name="com.gigaspaces" level="ERROR"/>
        <AsyncLogger name="com.j_spaces" level="ERROR"/>
        <AsyncLogger name="com.sun.jini" level="ERROR"/>
        <AsyncLogger name="net.jini" level="ERROR"/>
        <AsyncLogger name="org.apache" level="WARN"/>
        <AsyncLogger name="org.apache.cxf" level="WARN"/>
        <AsyncLogger name="org.springframework.beans.factory" level="WARN"/>
        <AsyncLogger name="org.mule" level="INFO"/>
        <AsyncLogger name="com.mulesoft" level="INFO"/>
        <AsyncLogger name="org.jetel" level="WARN"/>
        <AsyncLogger name="Tracking" level="WARN"/>
    </Loggers>
</Configuration>

Enable Custom Log4j Configurations in CloudHub

After you configure the Log4j appender, deploy the application to CloudHub and follow these steps to disable CloudHub logs:

  1. From Anypoint Platform, select Runtime Manager.

  2. Click Applications in the left menu.

  3. Click the Type column to display the details pane for the application.

  4. Click Manage Application.

  5. In the Settings page, click Disable CloudHub logs:

    Disable CloudHub logs option in the Applications Settings page
    Figure 1. The arrow shows the Disable CloudHub logs option in the Settings page.
  6. In the Disabling CloudHub logs confirmation window, select the checkboxes to verify that you want to disable CloudHub logs:

    Disabling CloudHub logs confirmation window
    Figure 2. The screen shows the Disabling CloudHub logs confirmation window.
  7. Click Apply Changes.

  8. Review your application settings to ensure they are correct.

  9. Click Apply Changes to restart your application.

After your application starts, logs start flowing to your custom Log4j appender and are viewable on your target logging system.

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.