输出日志

QuickDAO采用了slf4j作为日志门面框架,您可以自由选择日志实现层(logback,log4j等等).

QuickDAO在debug级别下会输出SQL日志.

假设您选择logback作为日志实现层,打印SQL日志的配置如下:

导入logback

  1. <dependency>
  2. <groupId>ch.qos.logback</groupId>
  3. <artifactId>logback-classic</artifactId>
  4. <version>1.2.3</version>
  5. </dependency>

配置logback.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration scan="true">
  3. <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
  4. <Target>System.out</Target>
  5. <encoder>
  6. <pattern>%-5level %d{yyyy-MM-dd HH:mm:ss.SSS} %c{10}:%L %m %n</pattern>
  7. </encoder>
  8. </appender>
  9. <!--改成INFO级别则不会输出SQL日志-->
  10. <logger name="cn.schoolwow.quickdao" level="DEBUG" additivity="false">
  11. <appender-ref ref="stdout"/>
  12. </logger>
  13. <root level="DEBUG">
  14. <appender-ref ref="stdout" />
  15. </root>
  16. </configuration>