Streaming MuleSoft Application Logs to Dynatrace with Log4j2

1. Introduction
In today’s API-driven world, observability is critical. While MuleSoft provides rich logging capabilities out of the box, organizations often need centralized log management to monitor performance, detect issues faster, and improve troubleshooting.
Dynatrace is a powerful observability platform that offers log ingestion, monitoring, and AI-powered anomaly detection. By integrating MuleSoft 4 logs with Dynatrace, we can achieve end-to-end visibility of APIs, integrations, and system flows.
This blog will walk through the steps to configure MuleSoft 4 logging with Log4j2 and send logs directly to Dynatrace Logs Ingest API.

2. Prerequisites
Before getting started, ensure you have:
MuleSoft Runtime 4.x
Dynatrace SaaS or Managed instance
An API Token in Dynatrace with the scope:
logs.ingestBasic knowledge of Log4j2 configuration
3. Why Integrate MuleSoft Logs with Dynatrace?
✅ Centralized logging and monitoring
✅ Real-time troubleshooting with Dynatrace dashboards
✅ AI-based anomaly detection on MuleSoft flows
✅ Unified observability across microservices, APIs, and Mule apps
✅ Faster root cause analysis by correlating logs, traces, and metrics
4. Creating a Dynatrace API Token
Log in to Dynatrace
Navigate to Apps > Access Token

- Click on Generate Access Token

Name the Token, Slect the expiration date
Select the scope →
ingest logs

- Copy the generated token → You’ll need it in your Log4j2 config

Configuring Log4j2 in MuleSoft
MuleSoft uses Log4j2 as its logging framework. We can configure a custom HTTP Appender to send logs directly to Dynatrace.
Appender for Dyantrace
<Http name="DynatraceAppender"
url="https://qru64311.live.dynatrace.com/api/v2/logs/ingest"
method="POST">
<Property name="Authorization">Api-Token XXXXXXXXXXX</Property>
<Property name="Content-Type">application/json</Property>
<JsonLayout compact="true" eventEol="true" />
</Http>
AsyncRoot:
<AppenderRef ref="DynatraceAppender" />
Example log4j2.xml:
<?xml version="1.0" encoding="utf-8"?>
<Configuration>
<!--These are some of the loggers you can enable. There are several more
you can find in the documentation. Besides this log4j configuration, you
can also use Java VM environment variables to enable other logs like network
(-Djavax.net.debug=ssl or all) and Garbage Collector (-XX:+PrintGC). These
will be append to the console, so you will see them in the mule_ee.log file. -->
<Appenders>
<RollingFile name="file"
fileName="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}test.log"
filePattern="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}test-%i.log">
<PatternLayout
pattern="%-5p %d [%t] [processor: %X{processorPath}; event: %X{correlationId}] %c: %m%n" />
<SizeBasedTriggeringPolicy size="10 MB" />
<DefaultRolloverStrategy max="10" />
</RollingFile>
<Http name="DynatraceAppender"
url="https://qru64311.live.dynatrace.com/api/v2/logs/ingest"
method="POST">
<Property name="Authorization">Api-Token XXXXXXXXXXX</Property>
<Property name="Content-Type">application/json</Property>
<JsonLayout compact="true" eventEol="true" />
</Http>
</Appenders>
<Loggers>
<!-- Http Logger shows wire traffic on DEBUG -->
<!--AsyncLogger name="org.mule.service.http.impl.service.HttpMessageLogger"
level="DEBUG"/ -->
<AsyncLogger name="org.mule.service.http" level="WARN" />
<AsyncLogger name="org.mule.extension.http" level="WARN" />
<!-- Mule logger -->
<AsyncLogger
name="org.mule.runtime.core.internal.processor.LoggerMessageProcessor"
level="INFO" />
<AsyncRoot level="INFO">
<AppenderRef ref="file" />
<AppenderRef ref="DynatraceAppender" />
</AsyncRoot>
</Loggers>
</Configuration>
Testing the Integration
Deploy a MuleSoft application
Generate logs by sending requests to your Mule APIs
Go to Dynatrace > Logs


Filter by
source="mule"or check for your MuleSoft application nameYou should see real-time logs flowing into Dynatrace.
Conclusion
By integrating MuleSoft 4 logs with Dynatrace, you gain real-time visibility, centralized observability, and AI-powered insights into your APIs and integration flows. This setup helps developers and operations teams proactively monitor, detect issues.
With this integration, MuleSoft logs become a powerful observability signal in Dynatrace, allowing you to correlate logs with metrics and traces for full-stack monitoring.


