java.util.logginglogging implementation used by Glassfish. One would, therefore, find that SLF4J calls would be transparently redirected to the Glassfish domain log, without a lot of configuration.
In order to configure logging for Hibernate on Glassfish, the JDK logger configuration in the
logging.propertiesfile of the Glassfish domain must be modified, to include any desired configuration changes. Simply put, one need not install log4j and the slf4j-log4j12 module in Glassfish and also provide log4j.properties to get Hibernate logging to work.
The following lines were added in the
logging.propertiesfile of the Glassfish domain (usually located in
$GLASSFISH_DOMAIN/config) to enable various loggers created by to provide a more verbose output:
To understand how those entries work, it is sufficient to understand that Hibernate uses SLF4J as a logging facade, delegating the actual writing of the log records to an underlying logger like log4j, logback or the JDK logger. Glassfish uses the JDK logger as the logging implementation, and to enable the calls on the SLF4J logger, to create entries in the Glassfish domain logs, one must have the SLF4J-JDK14 module (slf4j-jdk14-x.y.z.jar) installed in the classpath. The SLF4J-JDK14 module serves to adapt all SLF4J method calls to the JDK Logger interface, allowing any application (in this case, Hibernate) using SLF4J to have the log records written by the JDK logger. The adapter transforms the levels used by SLF4J to the ones known to the JDK logger as follows:
|SLF4J Level||JDK Logger Level|
By inference, an invocation within Hibernate using
Logger.trace()would be logged only if the JDK logger was configured to log messages at the FINEST level.