Java Platform, Standard Edition Java Flight Recorder Runtime Guide
Contents    Previous    Next

4 Controlling Recording Data by Using Templates

This chapter describes how to use templates for controlling the information that the flight recordings capture.

This chapter contains the following sections:

4.1 What You Can Control

Almost everything about Java Flight Recorder can be controlled through different kinds of settings. To control the amount of data that is recorded, you can configure the following information for each type of event:

  • Enabled; you can enable or disable each event type for a particular recording. Disabling events that occur often (such as synchronization events) helps reduce the size of the recording.

  • Threshold; you can filter events that have duration by setting a threshold. Events with shorter duration than the threshold are not saved.

  • Stack trace; you can enable or disable stack trace information for each event for the point from which the event is generated. Creating stack traces can be costly but can be extremely helpful to understanding why the event happened.

  • Request periods; you can configure the frequency with which a requestable events is requested by Java Flight Recorder.

Java Flight Recorder uses templates so that you do not need to modify all these configuration options every time you start a recording. Sets of best-known options for different tasks have been stored in both Mission Control templates and server-side templates. You can use these templates as is or you can modify them to suit your needs.


Even though the data format for a flight recording file is extremely compact, enabling too many event types in the recording, especially resource heavy onessuch as those that frequently collect stack tracesmight produce large amounts of data and increase performance overhead.

4.2 Flight Recording Templates

Before you start a recording, you can select a template to use in the Java Flight Recording wizard (see Figure 2-1). The template controls which events will be enabled during the recording. The following templates are available by default:

You can use the Template Manager to add a new template or modify existing ones. You can also export templates to share with others, and import templates from other environments.

4.2.1 Server-side Templates

Java Flight Recorder comes with two preconfigured server-side templates:

  • default.jfc, which is tuned for very low performance overhead and recommended for continuous production use.

  • profile.jfc, which provides a good balance between the amount of information available and the performance overhead introduced, making it ideal for profiling.

Both templates are located in the JDK installation directory under jre/lib/jfr. You can create you own server-side templates by copying the default ones and modifying your copy. Do not modify the default templates.

When starting a recording from the command line or by using a diagnostic command, you can specify the template to be used as an argument to the settings parameter. The following example shows how to start a recording lasting five minutes using the profile.jfc template on a running Java application named MyApp:

jcmd MyApp JFR.start duration=5min settings=profile

The following example shows how to start the MyApp application with Java Flight Recorder enabled and configured to use settings from the default.jfc template, and at the same time start a recording:

java MyApp -XX:+UnlockCpmmercialFeatures -XX:+FlightRecorder -XX:FlightRecorderOptions=defaultrecording=true,settings=default -XX:+StartFlightRecording

Contents    Previous    Next

Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.