Skip to content

Commit d0a699d

Browse files
committed
HHH-8865 - Create topical guide for logging
(cherry picked from commit 2d26135)
1 parent cd964a9 commit d0a699d

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

documentation/src/main/asciidoc/topical/index.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ NOTE: This is still very much a work in progress. <<helping,Help>> is definitely
99
== User Guides
1010

1111
* For information on generated (non-identifier) values, see the <<generated/GeneratedValues.adoc#,Generated Values Guide>>
12+
* For information on logging, see <<logging/Logging.adoc#,Logging Guide>>
1213
* Others coming soon
1314

1415
== Tooling
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
= Logging Guide
2+
:toc:
3+
4+
Since version 4.0, Hibernate has used the JBoss Logging library for its logging needs. Like SLF4J and
5+
Jakarta's commons-logging, JBoss Logging is a "logging bridge" providing integration with numerous logging
6+
frameworks. JBoss Logging was chosen because of its i18n support and its support for "message ids". This is largely
7+
the seminal documentation of JBoss Logging since JBoss Logging currently provides no documentation of its own.
8+
9+
10+
== Supported Back-ends
11+
12+
JBoss Logging understands the following back-ends as first-class citizens:
13+
14+
. JBoss LogManager (mainly used only inside the WildFly app server)
15+
. Log4j 2
16+
. Log4j 1
17+
. Slf4j
18+
. JDK logging
19+
20+
Note the order above, it is important. By default JBoss Logging will search the ClassLoader for the availability of
21+
classes that indicate one of the above "providers" being available. It does this in the order defined above. So,
22+
for example, if you have both JBoss LogManager and Slf4j available your classpath then JBoss LogManager will be used
23+
as it has the "higher precedence".
24+
25+
This can sometimes lead to an unwanted logging set up to be used. In such cases, JBoss Logging provides for you to
26+
tell it specifically which provider to use.
27+
28+
29+
=== Provider setting
30+
31+
JBoss Logging will first look for a setting with the key `org.jboss.logging.provider`, which can be set to one of the
32+
following values:
33+
34+
. jboss
35+
. jdk
36+
. log4j2
37+
. log4j
38+
. slf4j
39+
40+
41+
=== JDK Service
42+
43+
Next, JBoss Logging will look for a JDK service (see javadocs for +java.util.ServiceLoader+ for details) for its
44+
"provider" contract (+org.jboss.logging.Provider+). If multiple are available, it will use the first one returned by
45+
the ClassLoader.
46+
47+
48+
== Usage
49+
50+
Most of the time, the discovery process JustWorks. The discovery process relies on the jars available on the classpath.
51+
The jboss-logging jar is a required dependency of Hibernate and therefore will always need to be on the classpath.
52+
53+
* To use JBoss Logging with Log4j, the log4j jar would also need to be available on the classpath.
54+
* To use JBoss Logging with Log4j2, the log4j2 jar would also need to be available on the classpath.
55+
* To use JBoss Logging with Slf4j, the slf4j-api jar would also need to be available on the classpath *plus* any needed
56+
slf4j backend.
57+
58+
JDK Logging would be used if none of the other framework jars are available.
59+
60+
61+
== Log Categories of Interest
62+
63+
It is recommended that you familiarize yourself with the log messages sent from Hibernate. A lot of work has been put
64+
into making the Hibernate loggiong as detailed as possible, without making it unreadable. It is an essential
65+
troubleshooting device. Some log categories of particular interest include:
66+
67+
.Hibernate Log Categories of Interest
68+
|===
69+
|Category|Description
70+
71+
|org.hibernate.SQL
72+
|Log all SQL statements as they are executed with through JDBC
73+
74+
|org.hibernate.type.descriptor.sql
75+
|Log all values as they are bound to JDBC parameters and extracted from JDBC results
76+
77+
|org.hibernate.tool.hbm2ddl
78+
|Log all SQL DDL statements as they are executed during execution of any of the schema migration tools
79+
80+
|org.hibernate.pretty
81+
|Log the state of all entities (max 20 entities) associated with the session at flush time
82+
83+
|org.hibernate.cache
84+
|Log all second-level cache activity
85+
86+
|org.hibernate.hql.internal.ast.AST
87+
|Log HQL and SQL ASTs during query parsing
88+
89+
|org.hibernate
90+
|Log everything. This is a lot of information but it is useful for troubleshooting
91+
|===
92+
93+
94+
== Message Id Index
95+
96+
Coming soon.
97+

0 commit comments

Comments
 (0)