美文网首页
springmvc+jpa+hibernate 日志打印

springmvc+jpa+hibernate 日志打印

作者: 球球之家 | 来源:发表于2017-07-31 16:29 被阅读0次

    jar包添加

    <!--打印jdbc日志-->
            <dependency>
                <groupId>com.googlecode.log4jdbc</groupId>
                <artifactId>log4jdbc</artifactId>
                <version>1.2</version>
            </dependency>
    

    打印日志级别

    log4j.logger.log4jdbc.debug=warn
    log4j.logger.jdbc.audit=warn
    log4j.logger.jdbc.sqlonly=warn
    log4j.logger.jdbc.resultset=warn
    

    mysql配置

    connection.url=jdbc:log4jdbc:mysql://192.168.2.119:3306/rdms-pollution?useUnicode=true&characterEncoding=utf-8
    connection.username=root
    connection.password=root
    connection.driverClassName =net.sf.log4jdbc.DriverSpy
    

    spring datasource配置

    <property name="driverClassName" value="${connection.driverClassName}"/>
    

    entityManagerFactory中jpaProperties可以去掉下面两行了

    <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
    <prop key="hibernate.format_sql">true</prop>
    

    相关文章

      网友评论

          本文标题:springmvc+jpa+hibernate 日志打印

          本文链接:https://www.haomeiwen.com/subject/adywkxtx.html