anypointcloud / json-logger

Apache License 2.0
0 stars 0 forks source link

JSON Logger

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

Add this dependency to your application pom.xml

<groupId>cloud.anypoint</groupId>
<artifactId>json-logger</artifactId>
<version>2.2.1</version>
<classifier>mule-plugin</classifier>

Local Exchange Deployment

If you want to deploy JSON Logger to your organization's Exchange, you need to follow these steps:

  1. Update the groupId in pom.xml to the org id of your target business group (instead of cloud.anypoint).
  2. Add the Exchange Mule Maven Plugin to the plugins section of your pom.xml (don't forget to add a suitable version number, e.g., 0.0.23 as of the time of writing):
    <plugin>
    <groupId>org.mule.tools.maven</groupId>
    <artifactId>exchange-mule-maven-plugin</artifactId>
    <version>${exchange.mule.maven.plugin.version}</version>
    <executions>
        <execution>
            <id>validate</id>
            <phase>validate</phase>
            <goals>
                <goal>exchange-pre-deploy</goal>
            </goals>
        </execution>
        <execution>
            <id>deploy</id>
            <phase>deploy</phase>
            <goals>
                <goal>exchange-deploy</goal>
            </goals>
        </execution>
    </executions>
    </plugin>
  3. Add a <distributionManagement> element to your pom.xml (note the eu1. which is required only for the EU management plane):
    <distributionManagement>
    <repository>
        <id>anypoint-exchange-v3</id>
        <name>Anypoint Exchange V3</name>
        <url>https://maven.[eu1.]anypoint.mulesoft.com/api/v3/organizations/${project.groupId}/maven</url>
        <layout>default</layout>
    </repository>
    </distributionManagement>

    Also make sure, you have your credentials set up in your settings.xml accordingly (matching the repository id in this snippet).

  4. Execute mvn clean deploy

Please also 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/

Release notes

2.2.1 version - Release notes

2.2.0 version - Release notes

2.1.0 version - Release notes

2.0.1 version - Release notes

Bug fixes:

2.0.0 version - Release notes

New features:

Improvements:

More details in the coming blog post (stay tuned!)

1.1.0 version - Release notes

New features:

Improvements:

Authors

Support disclaimer

This extension is based on code developed by Andres Ramirez. It is a custom connector and it is provided under open source license. It is not officially supported by MuleSoft/Salesforce or anyone else.