You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/03/24 07:21:50 UTC
[GitHub] [shardingsphere] RaigorJiang opened a new issue #16333: Optimize the SQL log of Proxy, support to distinguish between schemas or users
RaigorJiang opened a new issue #16333:
URL: https://github.com/apache/shardingsphere/issues/16333
Hi community,
I have some ideas about optimizing the SQL log of ShardingSphere-Proxy.
### Background
Currently, by default, Proxy's log output is in the file `log/stdout.log`.
When `SQL-SHOW` is set to true, Proxy can log `Logic SQL` and `Actual SQL`, like this:
```sql
[INFO ] date&time [thread] ShardingSphere-SQL - Logic SQL: select * from t_order
[INFO ] date&time [thread] ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(table=Optional.empty, limit=Optional.empty, lock=Optional.empty, window=Optional.empty)
[INFO ] date&time [thread] ShardingSphere-SQL - Actual SQL: ds_0 ::: select * from t_order
[INFO ] date&time [thread] ShardingSphere-SQL - Actual SQL: ds_1 ::: select * from t_order
```
This is fine, but if I have multiple logic schemas, I can't tell in which schema the SQL in the log file is executed.
At the same time, since Proxy supports multi-user operations, it is impossible to identify which users performed SQL operations from the log file.
### Expectation
- Distinguish schemas in the same log:
```
[INFO ] date&time [thread] [sharding_db] ShardingSphere-SQL - Logic SQL: select * from t_order
[INFO ] date&time [thread] [sharding_db] ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(table=Optional.empty, limit=Optional.empty, lock=Optional.empty, window=Optional.empty)
[INFO ] date&time [thread] [sharding_db] ShardingSphere-SQL - Actual SQL: ds_0 ::: select * from t_order
[INFO ] date&time [thread] [sharding_db] ShardingSphere-SQL - Actual SQL: ds_1 ::: select * from t_order
[INFO ] date&time [thread] [another_db] ShardingSphere-SQL - Logic SQL: select * from t_order
[INFO ] date&time [thread] [another_db] ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(table=Optional.empty, limit=Optional.empty, lock=Optional.empty, window=Optional.empty)
[INFO ] date&time [thread] [another_db] ShardingSphere-SQL - Actual SQL: ds_0 ::: select * from t_order
[INFO ] date&time [thread] [another_db] ShardingSphere-SQL - Actual SQL: ds_1 ::: select * from t_order
```
- Distinguish schemas and users in the same log
```
[INFO ] date&time [thread] [sharding_db] [user1@xxx] ShardingSphere-SQL - Logic SQL: select * from t_order
[INFO ] date&time [thread] [sharding_db] [user1@xxx] ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(table=Optional.empty, limit=Optional.empty, lock=Optional.empty, window=Optional.empty)
[INFO ] date&time [thread] [sharding_db] [user1@xxx] ShardingSphere-SQL - Actual SQL: ds_0 ::: select * from t_order
[INFO ] date&time [thread] [sharding_db] [user1@xxx] ShardingSphere-SQL - Actual SQL: ds_1 ::: select * from t_order
[INFO ] date&time [thread] [another_db] [user2@xxx] ShardingSphere-SQL - Logic SQL: select * from t_order
[INFO ] date&time [thread] [another_db] [user2@xxx] ShardingSphere-SQL - SQLStatement: MySQLSelectStatement(table=Optional.empty, limit=Optional.empty, lock=Optional.empty, window=Optional.empty)
[INFO ] date&time [thread] [another_db] [user2@xxx] ShardingSphere-SQL - Actual SQL: ds_0 ::: select * from t_order
[INFO ] date&time [thread] [another_db] [user2@xxx] ShardingSphere-SQL - Actual SQL: ds_1 ::: select * from t_order
```
- Or split into different log files
```
├── logs
│ ├── another_db.log
│ ├── sharding_db.log
│ └── ...
```
### Plan
I plan to add [[MDC](https://logback.qos.ch/manual/mdc.html)](https://logback.qos.ch/manual/mdc.html) to the frontend thread of Proxy, save `schema` name and `user` name of the currently executing SQL.
In this way, when users need to distinguish schemas or users in the log, they can simply modify logback.xml to achieve this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [shardingsphere] totalo closed issue #16333: Optimize the SQL log of Proxy, support to distinguish between schemas or users
Posted by GitBox <gi...@apache.org>.
totalo closed issue #16333:
URL: https://github.com/apache/shardingsphere/issues/16333
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org