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

  • AI Assessments Are Everywhere
  • Logging What AI Agents Do in Salesforce: A Simple One-Object Audit Framework
  • Token Attribution Framework for Agentic AI in CI/CD
  • The Middleware Gap in AI Agent Frameworks

Trending

  • Engineering Closed-Loop Graph-RAG Systems, Part 2: From Prompts to Rules
  • Frame Buffer Hashing for Visual Regression on Embedded Devices
  • The Middleware Gap in AI Agent Frameworks
  • Building a High-Throughput Distributed Sequence Generator Using the Hi-Lo Algorithm
  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

  • AI Assessments Are Everywhere
  • Logging What AI Agents Do in Salesforce: A Simple One-Object Audit Framework
  • Token Attribution Framework for Agentic AI in CI/CD
  • The Middleware Gap in AI Agent Frameworks

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