FindBugs Logging Detectors The FindBugs logging detectors report common logging violations with respect to the Logging Guide. The GlassFish build is being modified to use these detectors by default. See below if you need to configure use of these detectors in your own workspace. Errors Detected The following table describes the patterns reported by the detectors. These patterns are currently all reported as Normal priority errors.
Pattern Name |
Description |
Category |
GF_UNCONDITIONAL_DEBUG_LOGGING |
Detects logging of computed expressions as FINE or lower level messages without Logger.isLoggable() check, e.g., LOGGER.fine("A" + localVariable + "B" ) |
CORRECTNESS |
GF_INCORRECT_CONDITIONAL_DEBUG_LOGGING |
Detects if the Logger.isLoggable() check is different from the corresponding level of the message being logged, e.g., if (LOGGER.isLoggable(Level.FINE) LOGGER.finer(("A" + localVariable + "B"); |
CORRECTNESS |
GF_LOG_DOMAINS_USAGE |
Finds usages of the obsoleted com.sun.logging.LogDomains API. |
CORRECTNESS |
GF_LOGGER_PARAM_OR_RETURN_TYPE |
Reports when a logger is being passed around as a method parameter or is being returned from a method. This is currently not reported by default. As per the recommendation, a Logger should be used within a module. |
EXPERIMENTAL |
GF_MISSING_LOGGER_INFO_ANNOTATION |
Finds a Logger declaration without a corresponding LoggerInfo annotation. |
CORRECTNESS |
GF_INVALID_LOGGER_NAME_PREFIX |
Detects logger name declarations where the prefix is not as per the prescribed conventions for the project such as a logger name not beginning with javax.enterprise. |
CORRECTNESS |
GF_MISSING_LOGMESSAGES_RB_ANNOTATION |
Finds Logger declaration with a resource bundle name that has no LogMessagesResourceBundle annotation. |
CORRECTNESS |
GF_INVALID_MSG_ID_PATTERN |
Finds log message ID without the recommended COMP_CODE-SUBSYSTEM-MSGID pattern such as NCLS-CORE-00001. |
CORRECTNESS |
GF_MISSING_LOGMESSAGE_INFO_ANNOTATION |
Finds log message ID usage with missing LogMessageInfo annotation. |
CORRECTNESS |
Configuration To configure the logging detectors, the FindBugs plugin configuration should be modified as follows:
<configuration>
<skip>${findbugs.skip}</skip>
<threshold>${findbugs.threshold}</threshold>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
<excludeFilterFile>
exclude-common.xml,${findbugs.exclude}
</excludeFilterFile>
<!-- findbugs detector configuration -->
<jvmArgs>-Dfindbugs.glassfish.logging.validLoggerPrefixes=javax.enterprise</jvmArgs>
<plugins>
<plugin>
<groupId>org.glassfish.findbugs</groupId>
<artifactId>findbugs-logging-detectors</artifactId>
<version>1.1-SNAPSHOT</version>
</plugin>
</plugins>
</configuration>
|