我正在寻找一种方法来记录这个框架http://ttddyy.github.io/datasource-proxy/docs/current/user-guide/index.html#query-logging-listener中包含的所有查询信息,但是我想排除查询参数的记录。有没有办法使用datasource-proxy来做到这一点?如果不是,我还有什么选择呢?我目前使用的是spring boot 2.1.1。
谢谢,布赖恩
发布于 2019-12-13 18:28:05
是的,它是..。在配置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);
}
}https://stackoverflow.com/questions/54450154
复制相似问题