Log4jdbc-remix installation Configuration

Source: Internet
Author: User
Tags log4j

1. MAVEN Installation Dependent

        <!--Logger -        <Dependency>            <groupId>Commons-logging</groupId>            <Artifactid>Commons-logging</Artifactid>            <version>1.2</version>        </Dependency>        <Dependency>            <groupId>Log4j</groupId>            <Artifactid>Log4j</Artifactid>            <version>${log4j.version}</version>        </Dependency>        <Dependency>            <groupId>Org.slf4j</groupId>            <Artifactid>Slf4j-api</Artifactid>            <version>${slf4j.version}</version>        </Dependency>        <Dependency>            <groupId>Org.slf4j</groupId>            <Artifactid>Slf4j-log4j12</Artifactid>            <version>${slf4j.version}</version>        </Dependency>        <Dependency>            <groupId>Org.lazyluke</groupId>            <Artifactid>Log4jdbc-remix</Artifactid>            <version>0.2.7</version>        </Dependency>

2, the Jdbc.properties configuration

Jdbc.driverclassname=net.sf.log4jdbc.DriverSpy
JDBC.URL=JDBC:log4jdbc: Mysql://localhost:3306/xdptest?useunicode=true&characterencoding=utf-8 &autoreconnect=truejdbc.username=rootjdbc.password=root

3. The configuration in spring:

<BeanID= "Datasourcespied"class="...">    < Propertyname= "Driverclass"value= "${jdbc.driverclassname}"/>    < Propertyname= "Jdbcurl"value= "${jdbc.url}"/>    < Propertyname= "User"value= "${jdbc.username}"/>    < Propertyname= "Password"value= "${jdbc.password}"/>    ...  </Bean>

<!--Note: Other references (such as transaction management configuration), with DataSource instead of datasourcespied <Bean id= "DataSource" class= " Net.sf.log4jdbc.Log4jdbcProxyDataSource "><constructor-arg ref = "Datasourcespied" /> </ Bean >

You can also format the SQL output, which is configured as follows:

<BeanID= "DataSource"class= "Net.sf.log4jdbc.Log4jdbcProxyDataSource">    <Constructor-argref= "Datasourcespied" />    < Propertyname= "Logformatter">       <Beanclass= "Net.sf.log4jdbc.tools.Log4JdbcCustomFormatter">         < Propertyname= "Loggingtype"value= "Multi_line" />         < Propertyname= "margin"value= "+" />         < Propertyname= "Sqlprefix"value= "SQL:::" />       </Bean>     </ Property>   </Bean>

4, log4j.properties configuration:

# # #-------------LOG4JDBC Configuration Example---------------# # #值设置方式: If off is set to off, if the turn on is set to on (default debug level) or (set output level, output)log4j.logger.jdbc.sqlonly = OFFlog4j.logger.jdbc.sqltiming= info,sqllog4j.logger.jdbc.audit=OFFlog4j.logger.jdbc.resultset=On  log4j.logger.jdbc.connection=OFFlog4j.logger.jdbc.resultsettable=Info,sql log4j.additivity.jdbc.sqlonly=falselog4j.additivity.jdbc.sqltiming=falseLog4j.additivity.jdbc.audidt=falseLog4j.additivity.jdbc.resultset=falselog4j.additivity.jdbc.connection=falselog4j.additivity.jdbc.resultsettable=false! The Appender used forthe JDBC API layer call logging above, SQL Onlylog4j.appender.sql=Org.apache.log4j.FileAppenderlog4j.appender.sql.File=d:/logs/Sql.loglog4j.appender.sql.Append=falseLog4j.appender.sql.layout=Org.apache.log4j.PatternLayoutlog4j.appender.sql.layout.ConversionPattern=%d{yyyy-mm-dd HH:mm:ss. SSS}%m%n%Nlog4j.additivity.sql=false

5. Reference Articles

Log4jdbc-remix Official website: https://code.google.com/p/log4jdbc-remix/

http://houfeng0923.iteye.com/blog/1266375

Log4jdbc-remix installation Configuration

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.