Publish JSON Logger on Exchange

Pankaj Badi
4 min readApr 14, 2022

--

How to published JSON logger on Anypoint Exchange

JSON Logger:

As the name suggests, the JSON logger prints the JSON format logs, which can be helpful when logging into any external log analytics tool such as ELK or Splunk.

JSON Logger connector looks like below in Anypoint Exchange.

Use Case:

  1. For any project if we are using a JSON logger it will be helpful for logging purposes to see the logs for any API which we implement.
  2. Make a clone of the JSON logger from the repository below mentioned in the reference.
  3. From the json-logger open the pom with any editor from the below screenshot.

4. In the pom file you will get <groupId>organizationId</groupId> tag.

5. If you see the color part is your organization-Id,which you will get in Anypoint platform as mentioned in the below step.

Anypoint Platform -> Management Center -> Access Management -> Organisation

6. The tags you have to use as mentioned below.

7.

<modelVersion>4.0.0</modelVersion>
<groupId></groupId>
<artifactId>json-logger</artifactId>
<version>2.0.1</version>
<packaging>mule-extension</packaging>
<name>JSON Logger — Mule 4</name>

8.

<distributionManagement>
<! — Target Anypoint Organization Repository →
<repository>
<id>Exchange2</id>
<name>Exchange2 Repository</name>
<url>
https://maven.anypoint.mulesoft.com/api/v2/organizations/organisationId/maven</url>
<layout>default</layout>
</repository>
</distributionManagement>

9.

<repositories>
<! — Shared Mule Services Repository →
<repository>
<id>Exchange2</id>
<name>Exchange2 Repository</name>
<url>
https://maven.anypoint.mulesoft.com/api/v2/organizations/organisationId/maven</url>
<layout>default</layout>
</repository>
</repositories>

10. In your .m2 folder you have to create the setting.xml file.

11. The below screenshot you see we have to write in the same manner.

<?xml version=”1.0" encoding=”UTF-8"?>
<settings xmlns=”http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=”http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>Exchange2</id>
<username>pankaj07</username>
<password>Pankaj@22</password>
</server>
</servers>
</settings>

12. In the setting.xml file write the<settings> tag. if you miss it then it will throw an error.

13. Now, go to the path below as show.

json-logger-mule-4.x\json-logger-mule-4.x\template-files

14. In the template-files you are able to see in the settings file we have the tags as below mentioned.

<server>
<id>MuleRepository</id>
<! — Provided by Support →
<username>username</username>
<password>password</password>
</server>
<! — Customer Exchange Repository →
<! — <server>
<id>Exchange2</id>
<! — NOTE: In order to be able to publish assets to exchange, this user will need Exchange Contributor Role
<username>username</username>
<password>password</password>
</server> →
<server>
<id>Exchange2</id>
<! — NOTE: In order to be able to publish assets to exchange, this user will need Exchange Contributor Role →
<username>username</username>
<password>password</password>

</server>

15. Once we done all the changes as mentioned above steps then open the cmd and write mvn clean deploy.

16. Below are some screenshot of your JSON logger build successfully.

17. In the below image you will see JSON logger BUILD SUCCESS.

18. Now, go to Anypoint Exchange and click on the JSON Connector. you are able to see the different tabs on it as shown below.

19. In Dependency Snippets you are able to find the different tabs.

Maven as below:

<dependency> <groupId>7c63b543-fbe9–4c06-b113–6dcc66f9e02c</groupId> <artifactId>json-logger</artifactId> <version>2.0.1</version> <classifier>mule-plugin</classifier> </dependency>

Gradle as below:

compile group: '7c63b543-fbe9-4c06-b113-6dcc66f9e02c', name: 'json-logger', version: '2.0.1', classifier: 'mule-plugin'

SBT as below:

libraryDependencies += “7c63b543-fbe9–4c06-b113–6dcc66f9e02c” % “json-logger” % “2.0.1” classifier “mule-plugin”

20. Now add the maven dependency of your project in the pom.xml as below.

21. If you are building any API you don’t have to and search in Exchange and search for that connector you have just add the dependency in the pom.xml and the connector will able to see in your mule palette as shown below.

22. Below is the Data that was logged using JSON Logger.

22. The biggest benefit of logging in JSON is that it has a structured format. This makes it possible to analyze application logs just like Big Data. It’s not just readable, but a database that can be queried for each and every field.

Conclusion:

By using JSON logger, we can logging into any external log analytics tool such as ELK or Splunk.

References:

  1. Clone Repo:

2. https://anypoint.mulesoft.com/

--

--

Pankaj Badi
Pankaj Badi

Written by Pankaj Badi

Hello Techies, I always want to learn new things and acquire skills as there is no end for learning and growing

No responses yet