Log4j_slf4j log4j. Properties

Source: Internet
Author: User

The log used by Hibernate is slf4j, and slf4j has various implementation strategies.

Using log4j is one of the methods. Jar package:

Log4j-1.2.16.jar

Slf4j-api-1.6.1.jar

Slf4j-log4j12-1.6.1.jar

 

The configuration file is placed in the SRC root directory. The configuration file name isLog4j. Properties

Example:

 

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} % 7 P % C: % L-% m % N

Log4j. rootlogger = warn, stdout

Log4j.logger.org. hibernate. SQL = debug

Log4j.logger.org. hibernate. JDBC = info

 

Usage in the class:

Private Static logger = logger. getlogger (addservlet. Class );

 

Logger. debug ("debug info ");

Logger.info ("info Info ");

Logger. Warn ("Warning Info ");

Logger. Error ("error Info ");

Logger. Fatal ("Fatal Info ");

 

Detailed explanation:

 

Levels are off, fatal, error, warn, info, debug, all in sequence.

Debug <info <warn <error <fatal.

 

D

Date and Time

 

C

Class Name

 

N

Line feed, that is, enter

 

M

Specific info

 

L

Row number

 

P

Priority

Http://blog.sina.com.cn/s/blog_647a022e01013zgy.html

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.