mybatisFlex日志打印修改
This commit is contained in:
parent
a8886b3153
commit
02c0b5c86f
|
|
@ -1,18 +0,0 @@
|
|||
package com.czg.config;
|
||||
|
||||
import com.mybatisflex.core.mybatis.FlexConfiguration;
|
||||
import com.mybatisflex.spring.boot.ConfigurationCustomizer;
|
||||
import org.apache.ibatis.logging.stdout.StdOutImpl;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Configuration
|
||||
public class MyConfigurationCustomizer implements ConfigurationCustomizer {
|
||||
|
||||
@Override
|
||||
public void customize(FlexConfiguration configuration) {
|
||||
configuration.setLogImpl(StdOutImpl.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +1,35 @@
|
|||
package com.czg.config;
|
||||
|
||||
import com.mybatisflex.core.audit.AuditManager;
|
||||
import com.mybatisflex.core.dialect.DbType;
|
||||
import com.mybatisflex.core.dialect.DialectFactory;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 自定义sql方言
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
//@Component
|
||||
@Configuration
|
||||
@Slf4j(topic = "mybatis-flex-sql")
|
||||
public class MybatisFlexConfig {
|
||||
// @Resource
|
||||
|
||||
public MybatisFlexConfig() {
|
||||
//开启审计功能
|
||||
AuditManager.setAuditEnable(true);
|
||||
|
||||
//设置 SQL 审计收集器
|
||||
AuditManager.setMessageCollector(auditMessage ->
|
||||
log.info("{},{}ms", auditMessage.getFullSql()
|
||||
, auditMessage.getElapsedTime())
|
||||
);
|
||||
}
|
||||
|
||||
// @Resource
|
||||
private MyCommonsDialectImpl myCommonsDialect;
|
||||
// @PostConstruct
|
||||
|
||||
// @PostConstruct
|
||||
public void init() {
|
||||
DialectFactory.registerDialect(DbType.MYSQL, myCommonsDialect);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue