DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • The Tectonic AI Platform: A Framework for Taming App Sprawl and Data Fragmentation
  • This One Spring Data JPA Pattern Cleaned Up to 3 Years of Repository Debt
  • Designing a Page Object Model + TestNG Hybrid Framework: Patterns That Actually Scale
  • Stop Fine-Tuning Everything: A Decision Framework for Model Adaptation

Trending

  • From Gherkin to Source Code Without Losing the Business Language
  • The Twelve-Factor Agents: Building Production-Ready LLM Applications
  • The Dark Side of Big Data: Pseudo-Science & Fooled By Randomness
  • Comprehensive Guide to Java String Formatting
  1. DZone
  2. Coding
  3. Frameworks
  4. Mule4: Logging and Error Handling Framework

Mule4: Logging and Error Handling Framework

Sample design of a logging and error handling asset.

By 
Ankur Bhuyan user avatar
Ankur Bhuyan
·
Jun. 25, 21 · Code Snippet
Likes (3)
Comment
Save
Tweet
Share
21.3K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

For any application development, reusable assets are more important, which can be shared across the organization's application. Based on requirements, it can be enhanced also. Based on my experience and knowledge, I prepare Mule4 logging and error handling framework, which can be more useful and also can get an idea to enhance according to project needs.

Design Logging Framework

Logging is most important while finding production issues, analyzing bugs, change code. It's also important to know how a request is being processing and responding back to the caller. I have come across the below 7 areas where we should log information/state of a request.

  1. While receiving a request by an App
  2. While the final response providing by an App to caller
  3. Request received in the main flow
  4. Response returned from the main flow
  5. Before calling a system (outbound call). 
    • It may be another app using HTTP, sftp, another connector
    • Sending message to Queue
    • Storing data into Database
  6. After receiving a response from a system.
  7. Logging the formatted error details, which can give clear information about the error. 

The working code can find here. 

Sample Log 

A screenshot of sample log details


Design Error Handling Framework

As with logging, error handling framework is also important to identify the root cause of an error. To make it easy, we need to prepare a proper error framework mechanism, which will give more information like the HTTP response code and its actual error description. Along with that, correlationId would be more important to track the issue in cloudHub/RTF.

The working code can be found here.

Sample Error Log and Response

A screenshot of the sample error log and response

Error Log

Response in Postman


How to Use the Framework

I have also developed an API that can give more insight into how to use this logging and error handling framework. Kindly visit here to find the code and Postman script to test the framework.

Framework

Opinions expressed by DZone contributors are their own.

Related

  • The Tectonic AI Platform: A Framework for Taming App Sprawl and Data Fragmentation
  • This One Spring Data JPA Pattern Cleaned Up to 3 Years of Repository Debt
  • Designing a Page Object Model + TestNG Hybrid Framework: Patterns That Actually Scale
  • Stop Fine-Tuning Everything: A Decision Framework for Model Adaptation

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook