160 likes | 267 Views
This presentation describes an example which shows how to log different levels of LOG messages
E N D
MULE LOGGING BY POLAKI SAIRAM
Mule Logger • We use the Logger component to log messages such as error messages, status notifications, or exceptions. • We can add a logger anywhere in a flow, and you can configure it to log anything: any string, any Mule expression, or any combination of strings and Mule expressions. • We can log 5 different levels of log messages in mule. They are ERROR, WARN, INFO, DEBUG and TRACE. The default level is INFO.
Logger - Example INFO 2017-06-23 11:45:12,276 [[logger1].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: This is INFO message
Logger - Example ERROR 2017-06-23 11:50:04,295 [[logger1].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: This is ERROR message
Logger - Example ERROR 2017-06-23 11:50:04,295 [[logger1].HTTP_Listener_Configuration.worker.01] org.mule.api.processor.LoggerMessageProcessor: This is ERROR message
Logger - Example Observe that DEBUG level logs are not logged in console. This is due to we are using default log4j2 configuration which logs messages of level greater than equal to INFO and DEBUG’s level is lesser than INFO.
LOG4J2.XML File Customization Change “org.mule” classes level to DEBUG and trigger the DEBUG request. Observe that many DEBUG logs are logged during the start of application.
LOG4J2.XML File Customization Another way to log this particular message is by changing http logger level to DEBUG.
Configuring Custom Logging Settings • To configure custom logging settings at server level change $MULE_HOME/conf/log4j2.xml file. • In Anypoint Studio, log4j2.xml appears in the src/main/resources path. • To use custom logging settings file sepeicfylog.configFile to log-settings-file.xml(someFileName) in mule-deploy.properties. The path to log-settings-file.xml can be either relative to working directory or an absolute path.
Configuring Custom Logging Settings • If this deployment property isn’t set, when an application is deployed, Mule looks for a config file following a child-first pattern, as listed below: • Look for a file called log4j2-test.xml in the application classpath • Look for a file called log4j2.xml in the application classpath • Look for a file called log4j2-test.xml in the domain classpath • Look for a file called log4j2.xml in the domain classpath • Look for a file called log4j2-test.xml in MULE_HOME/conf • Look for a file called log4j2.xml in MULE_HOME/conf • Apply default configuration.