---
schema_version: "1"
id: 08bc0fbcac7b927f60b57977e9e121b53ff3ec2a06ba8ee23d55e74ea333cd3f
title: Integrating with Your Logging System Using Log4j
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/runtime-fabric/2.5/use-log4j-appender.md
canonical_url: https://docs.mulesoft.com/runtime-fabric/2.5/use-log4j-appender
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 33c3cce105c3b14a983759ac18692750e48680a712bbf967af7002ce0ff12148
description: MuleSoft Documentation Site
release: "2.5"
latest: false
---
---
product: Runtime Fabric
version: 2.5
---

# Integrating with Your Logging System Using Log4j

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

You can use a Log4j appender to integrate your logging system with applications deployed to Runtime
Fabric.

You can use any Log4j appender. For information about configuring `log4j2.xml`, see the
[Log4j Configuration Syntax](https://logging.apache.org/log4j/2.x/manual/configuration.html#ConfigurationSyntax).

## Requirements and Restrictions

- MuleSoft Support doesn’t assist in implementing custom logging configurations or resolving issues
  caused by custom logging configurations.

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

- File appenders, such as FileAppender, RollingFileAppender, AnypointMonitoringFileAppender, and
  RandomAccessFileAppender, are removed automatically.

- When using custom Log4j configurations, both Mule runtime engine and application logs remain
  available in Anypoint Monitoring.

## Enabling Log4j

Custom Log4j configurations are disabled by default. When you install Runtime Fabric, the parameter
is disabled (`false`) in `Values.yaml`. You must set the value to `true`.

You can also enable custom Log4j configurations by running the following steps:

1.  From inside your cluster, run:

    kubectl -n rtf patch secret custom-properties -p '{\\"data\\": {\\"CUSTOM\_LOG4J\_ENABLED\\":
    \\"dHJ1ZQ==\\"}}'

2.  Restart the Runtime Fabric agent pod.

3.  Restart the application associated with the custom Log4j configuration.

> [!NOTE] Custom Log4j is only supported by Mule applications running on Mule runtime engine
> instances greater than or equal to Mule version 4.3.0. The Mule image must be built after Nov
> 17, 2022. For details, refer to the
> [Runtime Fabric Release Notes](https://docs.mulesoft.com/release-notes/runtime-fabric/runtime-fabric-runtimes-release-notes#november-14-2022).

## Example: Create a Log4j Configuration Using Splunk

For logs to be viewable in Runtime Fabric and flow to Splunk, configure the `SplunkHttp` Log4j
appender.

To enable the Log4j appender:

1.  Update the `log4j2.xml` configuration file with your logger settings and include the
    `SplunkHttp` Log4j appender.

    In Anypoint Studio, the `log4j2.xml` file is located in the `src/main/resources` directory.

```xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO" name="cloudhub" packages="com.mulesoft.ch.logging.appender">
    <Appenders>
    	<Console name="CONSOLE" target="SYSTEM_OUT">
            <PatternLayout pattern="[%d{MM-dd HH:mm:ss}] %-5p %c{1} [%t]: %m%n"/>
        </Console>
        <SplunkHttp name="SPLUNK"
        	source="${env:APP_NAME}"
        	host="${env:POD_NAME}"
        	sourceType="mule-app"
            url="${sys:splunk.host}"
            token="${sys:splunk.token}"
            index="main">
            <PatternLayout pattern="[%d{MM-dd HH:mm:ss}] %-5p %c{1} [%t]: %m%n" />
        </SplunkHttp>
    </Appenders>
    <Loggers>
        <AsyncRoot level="INFO">
            <AppenderRef ref="CONSOLE"/>
            <AppenderRef ref="SPLUNK"/>
        </AsyncRoot>
    </Loggers>
</Configuration>
```

1.  Ensure that the configuration includes the Splunk dependency:

    ```xml
    <dependency>
       <groupId>com.splunk.logging</groupId>
       <artifactId>splunk-library-javalogging</artifactId>
       <version>x.x.x</version>
    </dependency>
    *********
    ******************
    <repository>
       <id>splunk-artifactory</id>
       <name>Splunk Releases</name>
       <url>https://splunk.jfrog.io/splunk/ext-releases-local</url>;
    </repository>
    ```

    For the latest version of Splunk, see
    [GitHub](https://github.com/splunk/splunk-library-javalogging/tags).

After your application starts, logs start flowing to your custom Log4j appender, and you can view
them on your target logging system.

## See Also

- [MDC Logging](https://docs.mulesoft.com/mule-runtime/latest/logging-mdc)
