Build a log4j log environment using eclipse

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.