- All Implemented Interfaces and Traits:
- BeanPostProcessor
@CompileStatic
class DataSourceProxyBeanPostProcessor
extends Object
implements BeanPostProcessor
Spring bean post-processor that sets up datasourceproxy
intercepting for all DataSource
beans from the application context.
To use datasourceproxy features from a Spring Boot application, this bean post processor needs to be configured as a bean, and accompanying DataSourceProxyConfigurationProperties needs
to be enabled similar to the following example:
@EnableConfigurationProperties(DataSourceProxyConfigurationProperties)
@Configuration
class SpringBootConfig {
@Bean
static BeanPostProcessor dataSourceProxyBeanPostProcessor(ObjectProvider<DataSourceProxyConfigurationProperties> dataSourceProxyConfigurationPropertiesObjectProvider) {
return new DataSourceProxyBeanPostProcessor(dataSourceProxyConfigurationPropertiesObjectProvider)
}
}
This will configure and enable datasourceproxy's "query logging" and "slow query logging" features. Some aspects of these datasourceproxy features can be configured via
DataSourceProxyConfigurationProperties configuration properties. Usually, it is enough to configure appropriate loggers like in following example:
logging.level.klokwrk.datasourceproxy.queryLogger: DEBUG
logging.level.klokwrk.datasourceproxy.slowQueryLogger: WARN
For more configuration options, take a look at the documentation of DataSourceProxyConfigurationProperties.
It is worth mentioning that datasourceproxy's "query logging" feature is expanded by supporting filtering of queries that one wants to remove from the log. This is useful when we have reoccurring
queries, like in polling-a-database scenarios. Queries that need to be filtered out are specified as a list of regular expressions. When query string matches regular expression, it won't be
present in the log output. For example, following configuration will prevent logging of any updates to the token_entry
table.
klokwrk.datasourceproxy.query-logger.filtering-out-regular-expression-list: >
^update token_entry.*$
This 'filterable query logging' feature is implemented in org.klokwrk.lib.lo.datasourceproxy.Slf4jFilterableQueryLoggingListener
. - See Also:
- DataSourceProxyConfigurationProperties
- DataSourceProxyInterceptor