diff --git a/docs/reference-manual/native-image/JFR.md b/docs/reference-manual/native-image/JFR.md index 5298aa9bcbe5..df5be7622a19 100644 --- a/docs/reference-manual/native-image/JFR.md +++ b/docs/reference-manual/native-image/JFR.md @@ -59,7 +59,7 @@ You can configure the logging for the JFR system with a separate flag `-XX:Fligh The usage is: `-XX:FlightRecorderLogging=[tag1[+tag2...][*][=level][,...]]`. For example: ```shell --XX:FlightRecorderLogging=jfr,system=debug +-XX:FlightRecorderLogging=jfr+system=debug -XX:FlightRecorderLogging=all=trace -XX:FlightRecorderLogging=jfr*=error ``` diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/logging/JfrLogConfiguration.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/logging/JfrLogConfiguration.java index ac2e44cdf2cd..776bf83b34af 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/logging/JfrLogConfiguration.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/logging/JfrLogConfiguration.java @@ -92,8 +92,27 @@ private static void setLogTagSetLevels(JfrLogSelection[] selections) { private static void verifySelections(JfrLogSelection[] selections) { for (JfrLogSelection selection : selections) { if (!selection.matchesATagSet) { + // prepare suggestions + StringBuilder logTagSuggestions = new StringBuilder(); + for (Set valid : JfrLogConfiguration.LOG_TAG_SETS.values()) { + if (valid.containsAll(selection.tags)) { + boolean first = true; + for (JfrLogTag jfrLogTag : valid) { + if (!first) { + logTagSuggestions.append("+"); + } + logTagSuggestions.append(jfrLogTag.toString().toLowerCase(Locale.ROOT)); + first = false; + } + if (!logTagSuggestions.isEmpty()) { + logTagSuggestions.append(" "); + } + } + } + throw new IllegalArgumentException("No tag set matches tag combination " + - selection.tags.toString().toLowerCase(Locale.ROOT) + (selection.wildcard ? "*" : "") + " for FlightRecorderLogging"); + selection.tags.toString().toLowerCase(Locale.ROOT) + (selection.wildcard ? "*" : "") + " for FlightRecorderLogging" + + (logTagSuggestions.isEmpty() ? "" : ". Did you mean any of the following? " + logTagSuggestions)); } } }