All the log standards used in hibernate are SLF. SLF can be viewed as its interface, so we need to find its instance and make logs for us. We choose to use log4j as an instance.
1. To prevent conflicts, first remove the jar package of the slf4j-nop (which is also an SLF instance)
2. Add the jar package of log4j.
3. Add the conversion package slf4j-log4j
4. Add the log4j. properties configuration file to SRC.
The final jar package has: Log4j. Jar
Slf4j-api-1.6.1.jar
Slf4j-log4j12-1.5.8.jar
Log4j. properties:
### Direct log messages to stdout ###
Log4j. appender. stdout = org. Apache. log4j. leleappender
Log4j. appender. stdout. Target = system. Out
Log4j. appender. stdout. layout = org. Apache. log4j. patternlayout
Log4j. appender. stdout. layout. conversionpattern = % d {absolute} % 5 P % C: % L-% m % N
### Direct messages to file hibernate. Log ###
# Log4j. appender. File = org. Apache. log4j. fileappender
# Log4j. appender. file. File = hibernate. Log
# Log4j. appender. file. layout = org. Apache. log4j. patternlayout
# Log4j. appender. file. layout. conversionpattern = % d {absolute} % 5 P % c {1}: % L-% m % N
### Set log levels-for more verbose logging change 'info' to 'debug '###
Log4j. rootlogger = warn, stdout
# Log4j.logger.org. hibernate = info
# Log4j.logger.org. hibernate = debug
### Log hql query parser Activity
# Log4j.logger.org. hibernate. hql. Ast. Ast = debug
### Log just the SQL
# Log4j.logger.org. hibernate. SQL = debug
### Log JDBC bind parameters ###
# Log4j.logger.org. hibernate. type = info
# Log4j.logger.org. hibernate. type = debug
### Log schema export/update ###
Log4j.logger.org. hibernate. tool. hbm2ddl = debug
### Log hql parse trees
# Log4j.logger.org. hibernate. hql = debug
### Log cache activity ###
# Log4j.logger.org. hibernate. cache = debug
### Log transaction activity
# Log4j.logger.org. hibernate. Transaction = debug
### Log JDBC Resource Acquisition
# Log4j.logger.org. hibernate. JDBC = debug
### Enable the following line if you want to track down connection ###
### Leakages when using drivermanagerconnectionprovider ###
# Log4j.logger.org. hibernate. Connection. drivermanagerconnectionprovider = trace