Set Up
| Version | Min runtime version | Compatible Java versions | Description |
|---|---|---|---|
| 3.1.2 | 4.6.0 | Java 17, Java 11 | Stable release with JSON Serializer for JDK 8 datatypes (improved error handling) |
| 3.0.2 | 4.3.0 | Java 17, Java 11 | Made queue dependencies optional to reduce size |
| 2.2.3 | 4.3.0 | Java 17, Java 11 | Compatibility and stability updates |
1
Add Dependency to `pom.xml`
The snippet below always shows the latest release on Maven Central, currently 3.1.2.
Copy and paste the following Maven dependency snippet into your Mule application pom.xml under <dependencies>:
xml
<dependency>
<groupId>cloud.anypoint</groupId>
<artifactId>json-logger</artifactId>
<version>3.1.2</version>
<classifier>mule-plugin</classifier>
</dependency>2
Configure JSON Logger Global Element
Add a global JSON Logger configuration to your global.xml or flow file:
xml
<json-logger:config name="json-logger-config"
environment="dev" applicationName="test-app" applicationVersion="1.0.0"
disabledFields="content" contentFieldsDataMasking="password">
<!-- Optional: Configure external destination -->
<json-logger:external-destination>
<json-logger:amq-destination queueOrExchangeDestination="logs-queue"
clientId="{clientId}" clientSecret="{clientSecret}" />
</json-logger:external-destination>
</json-logger:config>Configuration Options:
- Identifiers: Application name, version and environment
- Masking Rules: Define fields to mask sensitive data in logs
- External Destinations: Route logs to Anypoint MQ, JMS queues, or AMQP destinations
- JSON Output: Customize JSON structure (simple changes)
3
Add JSON Logger Operation in Mule Flow
- Add a JSON Logger operation to your flow using Anypoint Studio, Anypoint Code Builder, or XML configuration.
- Configure the required
messageparameter and optional parameters as needed.