JOOQ和Logback [英] JOOQ with Logback

查看:133
本文介绍了JOOQ和Logback的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将springBoot与JOOQ一起使用,并希望记录生成的SQL.

I use springBoot with JOOQ and would like to log generated SQL's.

我将slf4J添加到我的maven依赖项和log4j.xml中,如下所示: JOOQ文档( http://www.jooq.org/doc/latest /manual/sql-execution/logging/).但是当jooq执行一些查询时,我的控制台中看不到任何日志.

I added slf4J to my maven dependency and log4j.xml like in JOOQ documenation (http://www.jooq.org/doc/latest/manual/sql-execution/logging/). But when jooq executes some queries, I can not see any log in my console.

我也在Google中搜索此问题,但找不到任何内容. SpringBoot使用logBack,所以我的路径中有logBack和slf4J. 是否可以对JOOQ使用logBack?我没有在JOOQ网站上获得任何说明.

I also search for this issue in google, but I couldn't find anything. SpringBoot uses logBack, so I have logBack and slf4J in my path. Is it possible to use logBack for JOOQ ? I didnt any instruction on JOOQ Site about it.

推荐答案

jOOQ的内置 JooqLogger 尝试按以下顺序解决可选的记录程序依赖项:

jOOQ's built-it JooqLogger tries to resolve an optional logger dependency in the following order:

  • 如果在类路径上找到slf4j,则使用
  • 否则,如果在类路径上找到log4j,则使用
  • 否则,使用java.util.logging

因此,只要JooqLogger在类路径上找到slf4j(例如,作为Spring Boot的传递依赖项),它将使用它作为日志记录框架.这是合理的,因为可以将slf4j配置为委托给任何其他日志记录框架,包括log4j和java.util.logging.

So, as soon as the JooqLogger finds slf4j on the classpath (e.g. as a transitive dependency from spring boot), it will use that as a logging framework. This is reasonable, because slf4j can be configured to delegate to any other logging framework, including log4j and java.util.logging.

因此,为了通过logback和Spring Boot启用jOOQ的调试日志记录,将以下logback.xml文件放在类路径根目录下就足够了:

So, in order to enable jOOQ's debug logging via logback and Spring Boot, it is sufficient to put the following logback.xml file at your classpath root:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>
    <logger name="org.jooq" level="DEBUG"/>
</configuration>

现在这也反映在更多信息可以在Spring Boot手册中找到: https://docs.spring.io/spring -boot/docs/current/reference/html/howto-logging.html

Some more ideas can be found here in the Spring Boot manual: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html

这篇关于JOOQ和Logback的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆