DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Key Takeaways From Integrating a RAG Application With LangSmith
  • Improving Java Application Reliability with Dynatrace AI Engine
  • Enabling Single-Sign-On in SaaS Application
  • Reimagining Innovation: How Citizen Application Development is Reshaping the Modern Enterprise

Trending

  • The Developer's Guide to Context-Aware AI: When Your Code Documentation Becomes Intelligent
  • Product-Led Software Delivery: Intelligent Platforms for DevOps at Scale
  • End-to-End Event Streaming With Kafka, Spring Boot and AWS SQS/SNS (Production-Ready Code Guide)
  • 11 Agentic Testing Tools to Know in 2026

Dynamically Change Logging Level of Application in Mule Run-Time

Use a JMX approach to create a Mule application that runs on Mule standalone and changes logging levels during runtime.

By 
Giridhar Chalumuri user avatar
Giridhar Chalumuri
·
Nov. 20, 18 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
15.5K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, I am going to create a Mule application that runs on Mule Standalone and changes logging levels dynamically (during runtime.). I am going to use the JMX approach.

Requirements

  • Mule EE Standalone to run your application.

  • Anypoint Studio to develop the application.

  • VisualVM.

Creating a Simple Application

Create a new project in Anypoint studio.

Add an HTTP listener in a new flow and configure it (I have configured it to listen to port 8081 with requests over the path "http://localhost:8081/hello").

Image title

Add 3 logger components to the flow and set the logging level of all the 3 loggers to "ERROR", "INFO" and "DEBUG". You can add corresponding log messages to each of the loggers (like the message "this is info logger" to logger component with log level = INFO and like this to other logger components).

Image title

That's it. we are done with creating the sample project. Go to project explorer, right-click on the project, and export it as a Mule deployable Archive.

Enabling JMX for Mule Runtime

To enable JMX, we need to update wrapper.conf file which sits in the directory ${MULE_HOME}/conf/wrapper.conf. Add the following lines to it.

# Dynamic logging 
wrapper.java.additional.22=-Dcom.sun.management.jmxremote
wrapper.java.additional.23=-Dcom.sun.management.jmxremote=true
wrapper.java.additional.24=-Dcom.sun.management.jmxremote.port=1099
wrapper.java.additional.25=-Dcom.sun.management.jmxremote.access.file=C:\mule-enterprise-standalone-4.1.4\conf/jmxremote.access
wrapper.java.additional.26=-Dcom.sun.management.jmxremote.password.file=C:\mule-enterprise-standalone-4.1.4\conf/jmxremote.password
wrapper.java.additional.27=-Dcom.sun.management.jmxremote.authenticate=true
wrapper.java.additional.28=-Dcom.sun.management.jmxremote.ssl=false

Next thing to do is, create two files "jmxremote.access " and "jmxremote.password " and make sure that access to "jmxremote.password" is restricted.

Making .password file access restricted (on windows):

- change the owner to be 'you' (required step!!)
Select jmx.password, Right-Mouse-Cick -> Properties -> Security -> Advanced -> Owner -> Edit
Select the single owner of this to be your username.

Select jmx.password, Right-Mouse-Cick -> Properties -> Security -> Advanced -> Change Permissions

Uncheck "Include inheritable permissions" and click Remove to remove all inherited permissions

Then click Add... to add read/write permissions for only your user: Enter your username as object name, and select for example 'Full Control'. Click Ok and exit out of properties.

Deploying the Application and Changing Logging Level Dynamically Using VisualVM

Copy and paste the Mule deployable archive of the sample project we created earlier, in the directory "${MULE_HOME}/apps".

Open the command prompt in the directory "${MULE_HOME}/bin" and type command "mule" and hit enter. This should start mule server and your application must be deployed and started.

Image title

Open visualVM, navigate to tools ----> plugins ----> Available plugins and add MBeans plugin.

On visualVM applications tab, under local, we can find our running application. Double click on it.

On the MBeans tab of our application, you can traverse to the component at org.apache.logging.log4j2, under Loggers, you can change any log4j2 bean's log level here.

Image title

You can check log files in your Mule runtime. Changes made here are reflected there.

application

Opinions expressed by DZone contributors are their own.

Related

  • Key Takeaways From Integrating a RAG Application With LangSmith
  • Improving Java Application Reliability with Dynatrace AI Engine
  • Enabling Single-Sign-On in SaaS Application
  • Reimagining Innovation: How Citizen Application Development is Reshaping the Modern Enterprise

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook