During O&M operations, O&M engineers can set a log generation level for the log module to obtain desired logs.
For the observer.log, election.log, and rootservice.log files, you can set a log generation level for the entire system, the current session, or the current statement. The priorities of the log generation levels set for the current statement, current session, and the entire system are in descending order.
The log generation level set for the entire system takes effect for all OBServers in the current cluster. You can set this level only under the sys tenant.
The log generation level set for the current session takes effect for the OBServer where the current tenant is located.
A session variable takes effect only on the current session.
A global variable does not take effect on the current session and takes effect only on sessions established upon re-logon.
The log generation level set for the current statement takes effect for the OBServer where the current statement is executed. The level takes effect only during statement execution.
The following section describes detailed information about the preceding three modes.
Set a log generation level for the entire system. You can use one of the following methods:
Use the
syslog_levelsystem parameter. For example, you can set the log generation level of the SQL module toDEBUGand that of the COMMON module toERROR.obclient > ALTER SYSTEM SET syslog_level='sql.*:debug, common.*:error';Run the bash
kill -41/42$pid command in the operating system.In the command,
kill -41is used to lower the level of program logs. For example, the current level of program logs is INFO. The log level is lowered to TRACE after you run thekill -41command.kill -42is used to raise the level of program logs. For example, the current level of program logs is INFO. The log level is raised to WARN after you run thekill -42command.
We recommend that you use the
syslog_levelsystem parameter. This is because when OceanBase Database refreshes configurations, it loads the specifiedob_log_levelvalue, and thus the kill command is invalid.Set a log generation level for the current session.
You can use the
ob_log_levelsystem parameter to set a log generation level. For example, you can set the log generation level of the SQL module toDEBUGand that of the COMMON module toINFO.obclient > SET @@ob_log_level='sql.*:debug, common.*:info';Set a log generation level for the current statement.
You can use a hint to set a log generation level. For example, you can set the log generation level of the SQL module to
DEBUGand that of the COMMON module toINFO. For more information about hints, see Optimizer hints in OceanBase Database SQL Tuning Guide.obclient > SELECT /*+log_level('sql.*:debug, common.*:info')*/ * FROM t;
Description
If you want to execute SQL statements containing hints on a MySQL client, you must log on to the client by using the -c option. Otherwise, the MySQL client will remove the hints from the SQL statements as comments, and the system cannot receive the hints.