The document summarizes a meetup event on logging and exception handling in MuleSoft. The agenda included introductions, discussions on common logging and exception handling best practices in MuleSoft, demonstrations of logging bad practices versus best practices, and a Q&A session. Resources on learning MuleSoft through online courses and instructor-led training were also provided.
5. Common Logging and Exception
For any integration, In order to facilitate service request tracking and incident
management it is required to have an effective logging and exception handling solution.
Within in MULESOFT, various components involved based on various deployment
patterns..
Standard logger
JSON logger
Cloud hub logger and supporting tools like.. Alerting, monitoring and email
notifications..
End of the day , its essential to have some log aggregation tools.. For example Splunk,
ELK and service incident management tool like SNOW, Remedy force..
6. Common Logging and Exception
Best practices recommended:
• Categorize the logs: Traceable, audit, exception logs..
• Separate the flows to for exception logs with logic (for example: business exceptions, data
validations, technical issues..)
• Have standard CDM format for logs based on the category and follows same for all the
integrations
• Handle exceptions and logs in the common project and have integration logic with in the
common project.
• Usage of correlation id / message id / business transaction id
• Define log related flows are Async
• Possible use MQ to avoid data loss and data consistency
• Logging steps @critical places
8. • The importance of logging
• Logging bad practice
• Best practices with logging
• Log4j 2
• Logging to different target systems
• Common Exception Handling
More Than Logging
10. 10
• No logging standards
• Hard coding
• Empty loggers
• Beware: CloudHub logs are limited by size
• 100MB or 30 days, whichever comes first
Bad Practice
12. 12
• Standards, standards, standards
• JSON
• Key-value pairs
• Other formats
• Informative messages
• Visibility into the system
• Enhance debugging
• Before and after external system calls
• Request identifier
• Trace transaction from end to end
• Ability to calculate latency
Best Practices
13. 13
• Dynamic error messages
• Persisting logs to a system
• Maintain historical logs
• Allows non-technical users to access and
support applications
• Not too much logging, not too little
Best Practices
14. LOG : (prefix :string, value :any)
Returns the specified value and also logs the value in the DataWeave representation with the specified
prefix.
Transform :
%dw 2.0
output application/json
var data={
"week" : ["Sunday","Monday"]
}
---
{
isPresent : log("logging in the array", data.week contains vars.lookup)
}
Console :
logging in the array - true
DataWeave Logging