To enable set in gradle

test {
    jvmArgs '-XX:+FlightRecorder', '-XX:StartFlightRecording=filename=myrecording.jfr'
}
bootRun {
    jvmArgs '-XX:+FlightRecorder', '-XX:StartFlightRecording=filename=myrecording.jfr'
}

javajfrjvm