The most robust way to check for debug mode is to query the Environment. This will allow you to detect that the mode has been enabled whether that's been done via a command line argument (--debug), system property (-Ddebug), environment variable (DEBUG=true), etc.
You can inject an instance of the Environment as you would any other dependency or you can implement EnvironmentAware. The getProperty(String) method can then be used to retrieve the value of the debug property. Spring Boot treats debug as being enabled if the debug property has a non-null value other than false:
private boolean isSet(ConfigurableEnvironment environment, String property) {
String value = environment.getProperty(property);
return (value != null && !value.equals("false"));
}