springboot使用druid记录sql脚本日志

方法一:

在application.properties设置开启slf4j过滤器

#开启slf4j过滤器
spring.datasource.druid.filter.slf4j.enabled=true

然后在logback-spring.xml文件配置日志输出


	  

方法二:

在application.properties设置开启stat过滤器,该过滤器用于统计,并设置过滤器启动慢SQL日志和设置慢SQL的时间

#默认开启druid统计,sql日志记录查看logback-spring.xml的配置
spring.datasource.druid.filter.stat.enabled=true
#开启慢sql日志
spring.datasource.druid.filter.stat.log-slow-sql=true
#设置记录慢sql的时间,单位毫秒,执行时间大于等于3秒的SQL脚本都会记录
spring.datasource.druid.filter.stat.slow-sql-millis=3000

然后在logback-spring.xml文件配置日志输出


	
		  
	

你可能感兴趣的:(#,springboot,springboot)