Huong Dan Java Logger – Part 4 – Build Global Configuration

Mule’s default Logger component is too simple to include only the log message, category, and level of that message.

Huong Dan Java Logger - Part 4 - Build Global Configuration

And with this layout, you can see, whenever adding a new endpoint Logger in a Mule Flow, you have to configure the Logger’s Category again. What if, in the future, I want to change the Category for all endpoints of the Logger? You can imagine, right? Therefore, moving the Category to a part of Global Configuration is the first thing I want to do.

The second part, I want to add to the Global Configuration section is the configuration section for the Correlation Id in the Mule ESB. You just imagine, because Mule ESB is an Enterprise Service Bus system, so there are a lot of requests from different systems to it, Correlation Id is like an identifier to distinguish this request from another request. This will make it easy to retrieve information about the requests that are having problems in the event of a failure.

To add Category and Correlation Id to the Global Configuration section of the Huong Dan Java Logger, open the ConnectorConfig class located in the com.huongdanjava.hdjlogger.config package, delete all body content of this class and add the following lines of code. :

In it, the Text class is in the com.huongdanjava.hdjlogger.constant package that defines text values, which are as follows:

As you can see in the code I just added, two new properties have been added and declared with the @Configurable annotation. This is a must have annotation to mark these configurable attributes. In the two new properties, I also use the @Placement annotation to specify the position of the two Correlation Id and Category cells. These two cells will be in the same group as Generic and the Category cell will be behind the Correlation Id.

Here, I also set the default value for Correlation Id using the annotation @Default.

The above is all I do for the Global Configuration section of Huong Dan Java Logger.

To be able to check the results, we have to solve one more problem.

Because of the default code of the Connector, I deleted, so the current code in the HuongDanJavaLoggerComponentConnector class is failing:

Huong Dan Java Logger - Part 4 - Build Global Configuration

For the simple, I will modify to remove the error code as follows:

OK, now you can Install or Udate our connector to see the result:

Huong Dan Java Logger - Part 4 - Build Global Configuration

 

Add Comment