Logger Component
This Core component helps you monitor and debug your Mule application by logging important information such as error messages, status notifications, payloads, and so on. You can add a Logger anywhere in a flow, and you can configure it to log a string that you specify, the output of a DataWeave expression you write, or any combination of strings and expressions.
- System Log: It is specific to MuleSoft runtime & “log4j.xml” configuration file is not accessible to an user.System logs contains log messages about the MuleSoft runtime life cycle (startup and shutdown) & status messages about MuleSoft application.
- Application Log: It is specific to MuleSoft application & “log4j.xml” configuration file is packaged inside MuleSoft application. It contains all log messages generated inside the Mule application, including System.out messages. We can configure custom log file appender to send application log data outside of cloudhub to external log file appender like splunk.
- Audit Log: It logs user interactions within Anypoint Platform, including logins, business groups creation, and environments creation.Only the organization owner can access all the audit logs data. It is useful to detect the access violations.
Log Levels:
- DEBUG level logs messages which could be useful in debugging an issue
- INFO level is designated for information related messages which tracks the progress of the mule flow.
- WARN level is best suited for temporary problems or unexpected behavior
- ERROR level should contain technical issues that need to be resolved for proper functioning of the application
How to View Logs of Mule Application :
- View App Logs : Check Anypoint Console / CloudHub.
- View the Runtime Log in Anypoint Studio:
- Click Anypoint Studio > About Anypoint Studio > Installation Details > Configuration > View Error Log:
Logging (log4j)
- Mule runtime engine (Mule) 4 uses Log4j 2 asynchronous logging by default, so the logging operation happens in a separate thread from the message processing, and the latter can continue without having to wait for the log operation to complete.
- The Logger component integrates with Log4j2, allowing the logged messages to be handled according to your Log4j2 configuration.
- You can configure Log4j2 to append custom log information, such as thread names, application names, or other contextual data.
- Log4j2 is designed for high performance, especially in multi-threaded applications like those built with Mule 4.
- Log4j2 allows logs to be written to various destinations, including files, the console, or external systems.
The above example makes the Runtime Manager agent log its state to a rolling log file in '$MULE_HOME/logs/custom_mule_agent.log', which rolls on a per day basis and until the file reaches a 250MB size.
Comments
Post a Comment