我正在寻找一种记录该框架http://ttddyy.github.io/datasource-proxy/docs/current/user-guide/index.html#query-logging-listener中包含的所有查询信息的方法,但是我想排除查询参数的记录。有没有办法使用datasource-proxy做到这一点?如果没有,我有什么选择?我目前正在使用Spring Boot 2.1.1。
谢谢, 布莱恩
答案 0 :(得分:0)
是的...当您配置DatasourceProxy时,您可以添加LoggingListener,例如对于SLF4J:
SLF4JQueryLoggingListener loggingListener = new SLF4JQueryLoggingListener();
loggingListener.setQueryLogEntryCreator(new NoParamsQueryLogEntryCreator);
this.dataSource = ProxyDataSourceBuilder.create(dataSource)
.name("MyDS")
.listener(loggingListener)
.build();
NoParamsQueryLogEntryCreator可能如下所示:
public class NoParamsQueryLogEntryCreator extends DefaultQueryLogEntryCreator {
@Override
protected SortedMap<String, String> getParametersToDisplay(List<ParameterSetOperation> params) {
// here you can manipulate the Parameter List ... obfucating or remove params
return super.getParametersToDisplay(params);
}
}