It is possible to activate/deactivate an event when launching a JFR. It is recommended to use a configuration files, see jfr --help configure.For example:
Then when launching the java process, the argument -XX:StartFlightRecording:filename=myFileName.jfr,settings=myCustomSettings.jfc must be supplied.To limit the number of events recorded, several JFR options can be used:
period
threshold
throttle (starting with Java 25)
It is also possible to scrub an existing JFR from an event to reduce its size via the scrub command, see jfr --help scrub.