I have a Spring boot app I'm trying to add database logging to which is better than

spring.jpa.properties.hibernate.show_sql=true

log4jdbc, from

https://github.com/marcosemiao/log4jdbc

seems to be the most up to date fork around, seems to format nicely, fills in parameters and adds timing, exactly what I want.

But when I configure it as stated in the readme, changing

spring.datasource.url=jdbc:mysql://localhost:3306/coindatabase?useSSL=false

to

spring.datasource.url=jdbc:log4jdbc:mysql://localhost:3306/coindatabase?useSSL=false

something seems to not like my reference to mysql and seems to try to fall back to H2:

Caused by: java.lang.RuntimeException: Driver org.h2.Driver claims to not accept jdbcUrl, jdbc:log4jdbc:mysql://localhost:3306/coindatabase?useSSL=false

at com.zaxxer.hikari.util.DriverDataSource.(DriverDataSource.java:106)

Is there some easy way to make this work together?

解决方案

log4jdbc for spring boot wrapper:

com.integralblue

log4jdbc-spring-boot-starter

which seems to pull in the implementation from:

org.bgee.log4jdbc-log4j2

log4jdbc-log4j2-jdbc4.1

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐