About the use of LOG4JDBC production SQL statements

Source: Internet
Author: User

1.Http://log4jdbc.googlecode.com/files/log4jdbc4-1.2.jar

Http://www.slf4j.org/download.html

Download Log4jdbc4-1.2.jar,Slf4j-api-1.7.5.jar, Slf4j-log4j12-1.7.5.jar three jar packages.

2. Modify the JDBC configuration file

< Bean id="DataSource"

class="Org.apache.commons.dbcp.BasicDataSource" destroy-method="Close" >

< Property name="Driverclassname" value="net.sf.log4jdbc.DriverSpy"/>

< Property name="url" value="jdbc:log4jdbc:mysql://localhost:3306/atpco"/ >

< Property name="username" value="${username}"/>

< Property name="password" ref="Ddns_password" />

</ Bean >

driverclassname modified to net.sf.log4jdbc.DriverSpy

The URL is based on the original JDBC: Changed to JDBC:LOG4JDBC: (add prefix 'log4jdbc: ')

3. Modify the log4j.properties configuration file

Add the following code to the original base:

#For JDBC

# Root Logger option

log4j.logger.jdbc.audit=INFO, file

Log4j.additivity.jdbc.audit=True

log4j.logger.jdbc.sqltiming=INFO, file

Log4j.additivity.jdbc.sqltiming=True

log4j.logger.jdbc.connection=INFO, file

Log4j.additivity.jdbc.connection=True

log4j.logger.jdbc.resultset=Fatal,file

Log4j.additivity.jdbc.resultset=false

log4j.logger.jdbc.sqlonly=Fatal,file

Log4j.additivity.jdbc.sqlonly=false

# Direct log messages to a log file

log4j.appender.file=Org.apache.log4j.RollingFileAppender

log4j.appender.file.file=C:/logs/log4jdbc.log

log4j.appender.file.maxfilesize=1MB

log4j.appender.file.maxbackupindex=10000

log4j.appender.file.layout=org.apache.log4j.PatternLayout

log4j.appender.file.layout.conversionpattern=%d{yyyy-mm-dd HH:mm:ss} %- 5p %c{1}:%l - %m%n

About the use of LOG4JDBC production SQL statements

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.