How to Change Log Levels in Mule at Runtime


As we've seen recently in this post, the Log4j framework provides us with different log levels for our Mule apps.
At development time we would be changing the log level for the different parts of our application to debug. For that, we would just update the log4j2.xml file and restart our app in Anypoint Studio. 

However, when the application is already in production and we need to debug for example a flow, a connector or any other part of the app that might be not working properly we can’t just stop the app, change the log level and start it again, as it would cause disruption for the consumers of the app.

Fortunately, there’s a way to modify log levels at runtime via Anypoint Runtime Manager without needing to restart the Mule application. 
Depending on the deployment model this is how to do it:

In Cloudhub 1.0

Add the following configuration to the Settings page of the application in the Logging tab (Runtime Manager UI), i.e., Anypoint Platform. → Runtime Manager → {Application Name} → Settings → Logging Tab.
For example, to change the logs of the HTTP connector to DEBUG:
DEBUG   org.mule.service.http.impl.service.HttpMessageLogger


In Cloudhub 2.0

Similarly to CH1.0, you need to specify the log level and the package of the logger in the Monitoring tab of the application settings


In RTF

In RTF, there’s no specific tab for Logging as in Cloudhub. In RTF the log level is controlled by a Property in runtime manager. The property name should contain the package name prefixed with the string “logging.level.”. A property to set DEBUG level into "org.mule.connectors" package will look like below:

logging.level.org.mule.connectors=DEBUG


Use this feature cautiously, as increasing log verbosity in production can affect performance.


Previous Post Next Post