VOOZH about

URL: https://thenewstack.io/remotely-record-java-logs-from-containers/

⇱ How to Remotely Record Java Logs from Containers - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2024-06-24 13:05:12
How to Remotely Record Java Logs from Containers
sponsor-azul,sponsored-post-contributed,
Containers / Java / Observability

How to Remotely Record Java Logs from Containers

Access Java Flight Recorder metrics to check your application’s health even when you don’t have access to the JVM’s command line.
Jun 24th, 2024 1:05pm by Matt Van Order
👁 Featued image for: How to Remotely Record Java Logs from Containers
Featured image by Galina Nelyubova on Unsplash.
Azul sponsored this post.

Java Flight Recorder (JFR) is the go-to technology for recording and viewing Java Virtual Machine (JVM) and system metrics. JFR logs reveal much about the running application, the JVM’s health and the system’s stability. You can access JFR logs by going into the command line or terminal and entering a few commands.

But what if you don’t have direct access to the command line or terminal on the system where the JVM is running, like when the JVM is running in a container?

Fortunately, you can obtain JFR logs without much configuration using JVM’s Java Management Extension (JMX) connector and a utility for profiling and analysis of JVM-based applications. You’ll want to have working knowledge of JVMs, JFR and JFR logs to follow along with this tutorial.

Set Up JMX on Your JVM

Before you can access your JVM outside of the command line or terminal, you must set up your JVM to be discoverable and accessible over remote connections. You can accomplish this simply by enabling the JVM’s JMX connector. Configure your Java application with the following VM parameters:

  • -Dcom.sun.management.jmxremote: Enables JMX/JMXRMI (Java Management Extensions Remote Management Interface) connectivity.
  • -Dcom.sun.management.jmxremote.host=<IP/Hostname>: Sets the address for the JMX connection. Use an external IP address or host name of the computer or container where the Java program is running.
  • -Dcom.sun.management.jmxremote.port=<port>: Sets the TCP port for the JMX connection.
  • -Djava.rmi.server.hostname=<IP/hostname>: Sets the address for the JMXRMI connection. Use the same IP/hostname you used for the JMX connection.
  • -Dcom.sun.management.jmxremote.rmi.port=<port>: Sets the TCP port for the JMXRMI connection. Use the same TCP port you used for the JMX connection.
  • -Dcom.sun.management.jmxremote.local.only=false: If you are connecting to the JVM from a different machine, you have to unbind ports from localhost.

Additionally, you may want to enable JMX authentication/SSL using:

  • -Dcom.sun.management.jmxremote.authenticate=true
  • -Dcom.sun.management.jmxremote.ssl=true

For example:

  • -Dcom.sun.management.jmxremote \
  • -Dcom.sun.management.jmxremote.host=192.168.0.166 \
  • -Dcom.sun.management.jmxremote.port=7091 \
  • -Djava.rmi.server.hostname=192.168.0.166 \
  • -Dcom.sun.management.jmxremote.rmi.port=7091 \
  • -Dcom.sun.management.jmxremote.local.only=false \
  • -Dcom.sun.management.jmxremote.authenticate=false \
  • -Dcom.sun.management.jmxremote.ssl=false \

Connect to a Remote JVM with Azul Mission Control

To start, you will need a utility for profiling and analysis of JVM-based applications. For demonstration purposes, I will use Azul Mission Control, which is free to download. If you don’t have Azul Mission Control, head over to the Azul Mission Control download page.

Other similar utilities include Oracle JDK Mission Control, VisualVM, JProfiler, YourKit Java Profiler, AppDynamics for Java, Dynatrace, New Relic APM, Glowroot and Java Flight Recorder (JFR).

In Azul Mission Control, go to the JVM Browser and click the Add JVM Connection button to create a new custom JVM connection.

👁 Go to the JVM Browser and click the Add JVM Connection button to create a new custom JVM connection

Specify the host name/IP address of the remote system and the JMX port number.

If JMX authentication is enabled, enter User and Password.

Click Test Connection to make sure your remote JVM is reachable, and click Finish.

👁 Click Test Connection to make sure your remote JVM is reachable, and click Finish.

Your remote JVM now appears in the JVM Browser.

👁 Remote JVM appears in the JVM Browser.

Depending on your network and container setup, port forwarding may need to be set up. Contact your network’s administrator if you need help with port forwarding.

Record a JFR From Your Remote JVM

Now that you’re connected to your JVM remotely, it’s time to make a JFR recording.

In Azul Mission Control, go to the JDK Browser, right-click your remote JVM connection and select Start Flight Recording.

👁 In Azul Mission Control, go to the JDK Browser, right-click remote JVM connection and select Start Flight Recording.

Select your preferred options and time intervals (either fixed-time recording or continuous recording) based on the JFR log’s size and/or age, and click Finish.

👁 Select your preferred options and time intervals and click Finish.

Your remote JFR recording has begun. You’re almost there!

Check the progress of the recording by expanding the remote JVM connection in the JVM Browser.

👁 Check the progress of the recording by expanding the remote JVM connection in the JVM Browser.

Once your recording has finished, your JFR log opens automatically in Azul Mission Control. You can now check the Outline tab to take a deeper look into your JVM’s performance portfolio.

Azul provides the Java platform for the modern cloud enterprise. Millions of Java developers, hundreds of millions of devices, and the world’s most highly regarded businesses trust Azul to power their applications with exceptional capabilities, performance, security, value and success.
Learn More
The latest from Azul
TRENDING STORIES
Matt Van Order is senior technical writer for Azul, where he ensures functionality and integrity of backend documentation systems. Previously he worked at Aveco.
Read more from Matt Van Order
Azul sponsored this post.
SHARE THIS STORY
TRENDING STORIES
Oracle is also a sponsor of The New Stack.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.