SlideShare a Scribd company logo
LOGGING BEST PRACTICE
IN MULE
USING
LOGGER COMPONENT
Govind Mulinti
2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
• Logging is been a key discussion whenever we go back
to an application for analysis or debugging. Having
proper logs in the application is first best practice that
we need to put into practice. The next thought should
be given to how these logs would be useful to the
supporting team members.
• Here we discuss a few best practices that we can
make use while creating the ESB applications which
will be very useful and appreciated by the support
team or whoever is looking at the application at a
later point in time.
2
Logging Best Practice in Mule ESB using Logger component
2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
Log4j configuration
First rule of thumb, we will be using log4j.properties file with in the
application/mule project that we wish to configure for appropriate logging. We
would configure the log4j to use the RollingFileAppender as below.
# Default log level
log4j.rootCategory=WARN, file
log4j.appender.file = org.apache.log4j.RollingFileAppender
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.File = ${mule.home}/logs/mule-app-myproject.log
log4j.appender.file.Append = true
log4j.appender.file.layout = org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%-5p %d [%t] %c: %m%n
3
2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
Using logger component
We can see that the default log level is set to WARN. This will enable us to
log the application related logs at INFO or DEBUG levels.
Now in the project go ahead and add the logger component. The properties
for one of the logger that I have used is shown below.
You are free to set the name and the message as per the naming and
messaging best practices. We are more interested now are in the ‘Level’ and
the ‘Category’ fields.
4
2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
Using the Log Level
• For ‘Level’ property, we suggest for all the custom messages should be set to
DEBUG level. Few log messages, which we wish to highlight or want them to be
available of at a higher level like an entry and exit of the flows, calls or some
specific functionality, can be set to INFO.
• The ‘Category’ property should be set to string similar to a package of a java
class.
• For example here we are using ‘com.ww.myproject.myfunction.flow2’.
• We should follow a practice so anyone using this can decode this string. Here I
have a base package of ‘com.ww’ which would be for an organization. Then the
project name, which is ‘myproject’ and then the flow name in that particular
project.
• So we can decode my package of which would be for the logger from the flow
named ‘flow2’ within an application denoted by name or known as ‘myproject’.
The additional element ‘myfunction’ is added which tells us that this flow is part
of that functionality that is implemented.
5
2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
Setting Log Level in log4j.properties
Now, that is good for our understanding. We will see how this can be used with in the log4j.properties.
We have seen that I have set the default log level to ‘WARN’. SO now if I wish to see the logs for my
application ‘myproject’ then I would add the following line in the log4j.properties file.
log4j.logger.com.ww.project=DEBUG
This would generate all the debug messages related to the project. This may generate a huge set of logs, so
you may want to get only the logs specific to the functionality that you are currently looking into. So that is
where this functionality element that we added into our package comes into play. To obtain this we would
update the parameters as shown below.
log4j.logger.com.ww.myproject.myfunction=DEBUG
Further to drill down you can enable or disable the logs specific to those flow to get more granular set of
messages as shown below for flow2. We can add multiple similar lines for each flow if we need such small
sets of logs for specific flows and avoid rest of the log messages.
log4j.logger.com.ww.myproject.myfunction.flow2=DEBUG
6
2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential
Conclusion
After debugging process this line should be either
commented or removed from the log4j.properties file so we
stop producing the huge set of logs file containing detailed
debug messages.
By putting this into practice we can ensure that the
customers as well as the support team would appreciate the
efforts put into this. This would help the support team to
look into the logs and get debug messages so as to analyze
the issue that are investigated. This would reduce the
investigation time, to narrow down to the root cause and to
provide appropriate fix with a short turnaround time.
7

More Related Content

What's hot (20)

PPTX
MuleSoft Deployment Strategies (RTF vs Hybrid vs CloudHub)
Prashanth Kurimella
 
PPTX
Patna MuleSoft Meetup Anypoint Cloudhub 2.0
shyamraj55
 
PPTX
What’s Mule 4.3? How Does Anytime RTF Help? Our insights explain.
Kellton Tech Solutions Ltd
 
PPTX
Micro services Architecture
Araf Karsh Hamid
 
PPTX
Best Practices in Implementing a Center for Enablement (C4E) within Your Orga...
MuleSoft
 
PDF
MuleSoft Surat Meetup#41 - Universal API Management, Anypoint Flex Gateway an...
Jitendra Bafna
 
PPTX
Manchester MuleSoft Meetup #6 - Runtime Fabric with Mulesoft
Akshata Sawant
 
PPSX
Microservices Architecture - Cloud Native Apps
Araf Karsh Hamid
 
PPSX
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Araf Karsh Hamid
 
PDF
Design patterns for microservice architecture
The Software House
 
PDF
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
Angel Alberici
 
PPTX
MuleSoft Architecture Presentation
Rupesh Sinha
 
PPTX
Introduction to CloudHub 2.0
NeerajKumar1965
 
PPTX
Azure kubernetes service (aks)
Akash Agrawal
 
PDF
MuleSoft PKO - C4E and Platform Insights
Angel Alberici
 
PDF
MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...
Jitendra Bafna
 
PDF
Containerising the Mule Runtime with Kubernetes & From Zero to Batch : MuleS...
Angel Alberici
 
PPTX
Best Practices for API Security
MuleSoft
 
PPTX
Platform engineering 101
Sander Knape
 
PDF
Microservice Architecture
tyrantbrian
 
MuleSoft Deployment Strategies (RTF vs Hybrid vs CloudHub)
Prashanth Kurimella
 
Patna MuleSoft Meetup Anypoint Cloudhub 2.0
shyamraj55
 
What’s Mule 4.3? How Does Anytime RTF Help? Our insights explain.
Kellton Tech Solutions Ltd
 
Micro services Architecture
Araf Karsh Hamid
 
Best Practices in Implementing a Center for Enablement (C4E) within Your Orga...
MuleSoft
 
MuleSoft Surat Meetup#41 - Universal API Management, Anypoint Flex Gateway an...
Jitendra Bafna
 
Manchester MuleSoft Meetup #6 - Runtime Fabric with Mulesoft
Akshata Sawant
 
Microservices Architecture - Cloud Native Apps
Araf Karsh Hamid
 
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Araf Karsh Hamid
 
Design patterns for microservice architecture
The Software House
 
MuleSoft Event Driven Architecture (EDA Patterns in MuleSoft) - VirtualMuleys63
Angel Alberici
 
MuleSoft Architecture Presentation
Rupesh Sinha
 
Introduction to CloudHub 2.0
NeerajKumar1965
 
Azure kubernetes service (aks)
Akash Agrawal
 
MuleSoft PKO - C4E and Platform Insights
Angel Alberici
 
MuleSoft Surat Meetup#42 - Runtime Fabric Manager on Self Managed Kubernetes ...
Jitendra Bafna
 
Containerising the Mule Runtime with Kubernetes & From Zero to Batch : MuleS...
Angel Alberici
 
Best Practices for API Security
MuleSoft
 
Platform engineering 101
Sander Knape
 
Microservice Architecture
tyrantbrian
 

Viewers also liked (10)

PPTX
Clustering of Mule ESB
Sreekanth Kondapalli
 
PPT
Mule - logger
Ankush Sharma
 
PPTX
Logger
krishashi
 
PPTX
Logging configuration in mule
Son Nguyen
 
PPTX
Microservices with mule
Govind Mulinti
 
PPTX
Canonical data model
Govind Mulinti
 
PPTX
Configuring log4j2
Anirban Sen Chowdhary
 
PPTX
Logger
Srilatha Kante
 
PPTX
Mule message structure
Srilatha Kante
 
PPTX
Mule debugging logging_in_mule
kunal vishe
 
Clustering of Mule ESB
Sreekanth Kondapalli
 
Mule - logger
Ankush Sharma
 
Logger
krishashi
 
Logging configuration in mule
Son Nguyen
 
Microservices with mule
Govind Mulinti
 
Canonical data model
Govind Mulinti
 
Configuring log4j2
Anirban Sen Chowdhary
 
Mule message structure
Srilatha Kante
 
Mule debugging logging_in_mule
kunal vishe
 
Ad

Similar to Logging best practice in mule using logger component (20)

DOC
Log4j
vasu12
 
PDF
10 Tips to improve your application logs
Vanessa Gomes
 
PPTX
Log4j2 - A deep dive into the logging services in Mulesoft with On-Prem deplo...
MysoreMuleSoftMeetup
 
PDF
Helpful logging with Java
roskakori
 
ODT
Log4 C Developers Guide
gzm55
 
PDF
Application Logging for large systems
Jane Prusakova
 
DOCX
JAVA LOGGING for JAVA APPLICATION PERFORMANCE
Rajendra Ladkat
 
PPTX
Java Logging
Zeeshan Bilal
 
PDF
P&MSP2012 - Logging Frameworks
Daniele Dell'Aglio
 
PPTX
Log4j is a reliable, fast and flexible
Ramakrishna kapa
 
PDF
Developer Fundamentals - Logging
Axel Irriger
 
PDF
Java Logging discussion Log4j,Slf4j
Rajiv Gupta
 
PDF
A Tool for Rejuvenating Feature Logging Levels via Git Histories and Degree o...
Raffi Khatchadourian
 
PPTX
Mule custom logging
Yamini Saraswathi Narimeta
 
PPT
Logback
Anubhav Shukla
 
PPTX
How to Use OWASP Security Logging
Milton Smith
 
PDF
Mining Development Knowledge to Understand and Support Software Logging Pract...
SAIL_QU
 
PDF
Are logs a software engineer’s best friend? Yes -- follow these best practices
Geshan Manandhar
 
PPTX
Application logging for fun and profit
Jane Prusakova
 
Log4j
vasu12
 
10 Tips to improve your application logs
Vanessa Gomes
 
Log4j2 - A deep dive into the logging services in Mulesoft with On-Prem deplo...
MysoreMuleSoftMeetup
 
Helpful logging with Java
roskakori
 
Log4 C Developers Guide
gzm55
 
Application Logging for large systems
Jane Prusakova
 
JAVA LOGGING for JAVA APPLICATION PERFORMANCE
Rajendra Ladkat
 
Java Logging
Zeeshan Bilal
 
P&MSP2012 - Logging Frameworks
Daniele Dell'Aglio
 
Log4j is a reliable, fast and flexible
Ramakrishna kapa
 
Developer Fundamentals - Logging
Axel Irriger
 
Java Logging discussion Log4j,Slf4j
Rajiv Gupta
 
A Tool for Rejuvenating Feature Logging Levels via Git Histories and Degree o...
Raffi Khatchadourian
 
Mule custom logging
Yamini Saraswathi Narimeta
 
How to Use OWASP Security Logging
Milton Smith
 
Mining Development Knowledge to Understand and Support Software Logging Pract...
SAIL_QU
 
Are logs a software engineer’s best friend? Yes -- follow these best practices
Geshan Manandhar
 
Application logging for fun and profit
Jane Prusakova
 
Ad

Recently uploaded (20)

PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PDF
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
PPTX
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PPTX
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PPTX
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
Thread In Android-Mastering Concurrency for Responsive Apps.pdf
Nabin Dhakal
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
GridView,Recycler view, API, SQLITE& NetworkRequest.pdf
Nabin Dhakal
 
MiniTool Power Data Recovery Full Crack Latest 2025
muhammadgurbazkhan
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
MailsDaddy Outlook OST to PST converter.pptx
abhishekdutt366
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Migrating Millions of Users with Debezium, Apache Kafka, and an Acyclic Synch...
MD Sayem Ahmed
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 

Logging best practice in mule using logger component

  • 1. LOGGING BEST PRACTICE IN MULE USING LOGGER COMPONENT Govind Mulinti
  • 2. 2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential • Logging is been a key discussion whenever we go back to an application for analysis or debugging. Having proper logs in the application is first best practice that we need to put into practice. The next thought should be given to how these logs would be useful to the supporting team members. • Here we discuss a few best practices that we can make use while creating the ESB applications which will be very useful and appreciated by the support team or whoever is looking at the application at a later point in time. 2 Logging Best Practice in Mule ESB using Logger component
  • 3. 2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential Log4j configuration First rule of thumb, we will be using log4j.properties file with in the application/mule project that we wish to configure for appropriate logging. We would configure the log4j to use the RollingFileAppender as below. # Default log level log4j.rootCategory=WARN, file log4j.appender.file = org.apache.log4j.RollingFileAppender log4j.appender.file.MaxFileSize=1MB log4j.appender.file.MaxBackupIndex=10 log4j.appender.file.File = ${mule.home}/logs/mule-app-myproject.log log4j.appender.file.Append = true log4j.appender.file.layout = org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%-5p %d [%t] %c: %m%n 3
  • 4. 2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential Using logger component We can see that the default log level is set to WARN. This will enable us to log the application related logs at INFO or DEBUG levels. Now in the project go ahead and add the logger component. The properties for one of the logger that I have used is shown below. You are free to set the name and the message as per the naming and messaging best practices. We are more interested now are in the ‘Level’ and the ‘Category’ fields. 4
  • 5. 2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential Using the Log Level • For ‘Level’ property, we suggest for all the custom messages should be set to DEBUG level. Few log messages, which we wish to highlight or want them to be available of at a higher level like an entry and exit of the flows, calls or some specific functionality, can be set to INFO. • The ‘Category’ property should be set to string similar to a package of a java class. • For example here we are using ‘com.ww.myproject.myfunction.flow2’. • We should follow a practice so anyone using this can decode this string. Here I have a base package of ‘com.ww’ which would be for an organization. Then the project name, which is ‘myproject’ and then the flow name in that particular project. • So we can decode my package of which would be for the logger from the flow named ‘flow2’ within an application denoted by name or known as ‘myproject’. The additional element ‘myfunction’ is added which tells us that this flow is part of that functionality that is implemented. 5
  • 6. 2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential Setting Log Level in log4j.properties Now, that is good for our understanding. We will see how this can be used with in the log4j.properties. We have seen that I have set the default log level to ‘WARN’. SO now if I wish to see the logs for my application ‘myproject’ then I would add the following line in the log4j.properties file. log4j.logger.com.ww.project=DEBUG This would generate all the debug messages related to the project. This may generate a huge set of logs, so you may want to get only the logs specific to the functionality that you are currently looking into. So that is where this functionality element that we added into our package comes into play. To obtain this we would update the parameters as shown below. log4j.logger.com.ww.myproject.myfunction=DEBUG Further to drill down you can enable or disable the logs specific to those flow to get more granular set of messages as shown below for flow2. We can add multiple similar lines for each flow if we need such small sets of logs for specific flows and avoid rest of the log messages. log4j.logger.com.ww.myproject.myfunction.flow2=DEBUG 6
  • 7. 2015 © WHISHWORKS. All rights reserved. WHISHWORKS Confidential Conclusion After debugging process this line should be either commented or removed from the log4j.properties file so we stop producing the huge set of logs file containing detailed debug messages. By putting this into practice we can ensure that the customers as well as the support team would appreciate the efforts put into this. This would help the support team to look into the logs and get debug messages so as to analyze the issue that are investigated. This would reduce the investigation time, to narrow down to the root cause and to provide appropriate fix with a short turnaround time. 7