Fix not able to override datasource-proxy log-level (#1976)

* Fix datasource-proxy log-level is not working

- Aligned default values of `Query` & `SlowQuery` in
  `TraceJdbcProperties.DataSourceProxyProperties`
  and `DataSourceProxyProperties`
- Add code to copy properties of `Query` and `SlowQuery` in
  `DataSourceProxyConfiguration`
- Add test case to check if `log-level` can be override or not.

Fixes gh-1973

* Disable query log listener by default

- By default `QueryLogListener` and `LoggingQueryLogListener`
  will be disabled, dev need to enable it by using properties
- By default `Slf4j` will be enlabled for query logging
  so by adding below property slow query logging will be enabled
  `spring.sleuth.jdbc.datasource-proxy.slow-query.enable-logging=true`
  this property will register `SLF4JSlowQueryListener`

* Add docs for how-to enable data-proxy query logs
This commit is contained in:
Chintan Radia
2021-06-18 13:06:28 +05:30
committed by GitHub
parent 7c4d8b1479
commit f7eb398917
6 changed files with 67 additions and 12 deletions

View File

@@ -31,6 +31,7 @@
|spring.sleuth.jdbc.datasource-proxy.query.enable-logging | `false` | Enable logging all queries to the log.
|spring.sleuth.jdbc.datasource-proxy.query.log-level | `DEBUG` | Severity of query logger.
|spring.sleuth.jdbc.datasource-proxy.query.logger-name | | Name of query logger.
|spring.sleuth.jdbc.datasource-proxy.slow-query.enable-logging | `false` | Enable logging slow queries to the log.
|spring.sleuth.jdbc.datasource-proxy.slow-query.log-level | `WARN` | Severity of slow query logger.
|spring.sleuth.jdbc.datasource-proxy.slow-query.logger-name | | Name of slow query logger.
|spring.sleuth.jdbc.datasource-proxy.slow-query.threshold | `300` | Number of seconds to consider query as slow.

View File

@@ -720,6 +720,9 @@ Please check the <<appendix.adoc#appendix,appendix>> page under `spring.sleuth.j
You can configure P6Spy manually using one of available configuration methods. For more information please refer to the http://p6spy.readthedocs.io/en/latest/configandusage.html[P6Spy Configuration Guide].
By default logging queries will be disabled, set `spring.sleuth.jdbc.datasource-proxy.slow-query.enable-logging` to `true` to enable logging slow queries
and set `spring.sleuth.jdbc.datasource-proxy.query.enable-logging` to `true` to enable logging all queries.
In order to disable this instrumentation set `spring.sleuth.jdbc.enabled` to `false`.
[[sleuth-session-integration]]