Logging is been a key discussion whenever we go back to an application for analysis or debugging. Having the right information in the logs of an application is one of the best practices in software engineering . The next thought should be given on to how these logs would be useful to the supporting team members.
Understanding the Pakistan Budgeting Process: Basics and Key Insights
Logging Best Practice in Mule ESB using Logger component
1. Logging Best Practice in Mule ESB using
Logger component
WHISHWORKS has emerged as a global leader in IT services and
consulting.
We have built a Centre of Excellence and developed deep skills in the areas of Big
Data and System Integration.
Continuously Innovate Niche Products and Services, in an environment of
People First, for Client Value Creation, to achieve Revenues of USD 30
million by the year 2020.
VISION
Think Fresh, Create Value
WHISHWORKS | All Rights Reserved .
2. Logging Best Practice in Mule ESB using Logger
component
Logging is been a key discussion whenever we go back to an
application for analysis or debugging. Having the right information in the logs
of an application is one of the best practices in software engineering . The
next thought should be given on to how these logs would be useful to the
supporting team members.
Here we will discuss a few best practices that can be used while
creating ESB applications which are very useful and appreciated by the
support team or whoever is looking at the application at a later point in
time.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.
WHISHWORKS | All Rights Reserved .
3. We would configure the log4j to use the Rolling File
Appender 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
WHISHWORKS | All Rights Reserved .
4. We have seen that default log level can be set to ‘WARN’. S0, now if we wish
to see the logs for the application ‘myproject’ then we can add the following line at
the end in the log4j.properties file.
log4j.logger.com.ww.project=DEBUG
This would generate all the debug messages related to the project. Also, this
may generate a huge set of logs, and we may want to get only the logs specific to
the functionality that we 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
WHISHWORKS | All Rights Reserved .
5. Further to drill down, we can also enable or disable the logs specific to those
flow in order 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
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.
We can ensure that the operations and support team would appreciate the
efforts to have effective logging that will help in root cause analysis , performance
monitoring and resolve time sensitive critical application issues.
WHISHWORKS | All Rights Reserved .
6. Contact Now: IT’S FREE
Log on to: http://www.whishworks.com/
http://www.whishworks.com/blog/esb/logging-best-practice-in-mule-esb
WHISHWORKS | All Rights Reserved .
7. Contact Now: IT’S FREE
Log on to: http://www.whishworks.com/
http://www.whishworks.com/blog/esb/logging-best-practice-in-mule-esb
WHISHWORKS | All Rights Reserved .