mulesoft-consulting / json-logger

Drop-in replacement for default Mule Logger that outputs a JSON structure based on a predefined JSON schema
MIT License
69 stars 215 forks source link

JSON Logger - Mule 4

Drop-in replacement for default Mule Logger that outputs a JSON structure based on a predefined JSON schema.

Why?

For these reasons and based on previous customer experiences, I created this generic Java SDK JSON Logger Connector.

How?

As mentioned above, this is a Java SDK based Mule 4 connector. However, in order to maximize customization to each customer's requirements while avoiding steep Java SDK learning curves, you can easily modify the output JSON data structure as well as connector configuration by editing 2 simple JSON schemas provided under:

/json-logger/src/main/resources/schema/

In a nutshell, by defining the output JSON schema as well as providing some additional SDK specific details (e.g. default values, default expressions, etc.), we can dynamically generate a module that aligns to those schemas.

Installation

Please check these blogposts for more details:

PART 1: https://blogs.mulesoft.com/dev/anypoint-platform-dev/json-logging-in-mule-4-getting-the-most-out-of-your-logs/

PART 2: https://blogs.mulesoft.com/dev/api-dev/json-logging-in-mule-4/

Running the provided deployment script will deploy JSON Logger to your Organization's Exchange:

e.g. ./deploy-to-exchange.sh

PS1. You can only use the deploy.sh script once (unless you manually delete the previous asset from your exchange within 7 days of deployment or increase the version in the pom.xml) as you can't deploy the same version to Exchange

PS2. For EU Control Plane deployment you have to modify the <distributionManagement> element inide the json-logger/pom.xml in the following way:

<distributionManagement>
  <!-- Target Anypoint Organization Repository -->
    <repository>
      <id>Exchange2</id>
        <name>Exchange2 Repository</name>
        <url>https://maven.eu1.anypoint.mulesoft.com/api/v1/organizations/${project.groupId}/maven</url>
        <layout>default</layout>
    </repository>
</distributionManagement>

Release notes HERE

Author

Support disclaimer

In case you haven't noticed the type of license for the source code, this is provided as a side project under MIT open source license which means it won't be officially supported by MuleSoft as it is considered a custom connector.