Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

457
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda