Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

463
Visualizações
Logging SQL statements in Spring Boot + jdbi

I'm using datasource with DBI:

@Autowired
DataSource dataSource;

@Bean
public DBI dbiBean() {
    DBI dbi = new DBI(dataSource);
    return dbi;
}

I have no idea how to configure logging framework to log SQL statements. I tried:

logging:
 level: 
   org.hibernate: TRACE
   org.skife.jdbi: TRACE
   java.sql: TRACE

but it doesn't work.

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Add the line to set the SQL log like this. Use either SLF4JLog or another logger there.

@Bean
public DBI dbiBean() {
    DBI dbi = new DBI(dataSource);
    dbi.setSQLLog(new SLF4JLog());
    return dbi;
}
about 4 years ago · Santiago Trujillo Relatório

0

Starting from JDBI version 3.2.0, SqlLogger interface should be used:

  Jdbi jdbi;
  jdbi.setSqlLogger(new Slf4JSqlLogger());

As documentation says, Slf4JSqlLogger is a simple SqlLogger that emits some diagnostic information about Jdbi usage. You can provide existing instance of Slf4J Logger class to the Slf4JSqlLogger constructor then the provided logger will be used to log SQL statements, otherwise, if no-args constructor is used, a logger called org.jdbi.sql will be created and used.

SQL statements are logged with debug log level, so in order to see them it might be necessary to set the root level of the logging framework to debug.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda