Contact Free trial Login

CloudHub Custom Log Appender

logo cloud active logo hybrid disabled logo server disabled logo pcf disabled

With the option to disable CloudHub logs, customers can supply their own Log4j configurations to integrate with their own logging systems.

Create Your Log4j Configuration

  • This feature is only available on request. If you do not have access to this feature, you can request it via the support portal.

  • MuleSoft is not responsible for lost logging data due to misconfiguration of your own Log4j appender.

  • MuleSoft is also not responsible for misconfigurations that result in performance degradation, running out of disk space, or other side effects.

  • To configure logs to flow to both your log system and CloudHub, read the directions below. Note that the UI will continue to warn you that logs in CloudHub will not be available.

  • When you disable the default CloudHub application logs, then only the system logs are available. For application worker logs, please check your own application’s logging system. Downloading logs is not an option in this scenario.

  • Only Asynchronous log appenders can be used, Synchronous appenders should not be used.

To enable your own Log4j appender, you need to first create a log4j2.xml configuration file with your log settings. In Anypoint Studio, this file must reside in the src/main/resources directory. For details on creating your own Log4j configuration, please see the Log4j documentation.

If you wish to have logs flow to both your own logging system, and be viewable in CloudHub, you must configure the CloudHub Log4j appender. MuleSoft recommends this as the base configuration for your log configuration. It sends log data to CloudHub and provides a local log file in case it’s needed for remote debugging purposes by MuleSoft staff.

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

Once you’ve configured your Log4j appenders, deploy the application to CloudHub and tell CloudHub you are supplying your own Log4j configuration:

  1. Log into Anypoint Platform and click CloudHub.

  2. Click an application to expand the details view:

    CHApps
  3. Click Settings > Disable CloudHub Logs.

    DisableCHLogs

    The verification prompt appears:

    DisableCHLogsVerification
  4. Click Apply Changes.

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

  6. Click Apply Changes to restart your application.

Once your application starts, logs should start flowing to your custom Log4j appender and will be viewable in your target system.

If you did not use the CloudHub Log4j appender specified above, only system logs will be available. System logs tell you the status of your worker deployment and if your application started correctly, but do not provide any application logs.