OceanBase Database supports seven log levels. The following table describes the log levels in descending order.
| Log level | Description |
|---|---|
| ERROR | Critical errors. Logs at this level record system failure information. The system is unavailable until the errors are handled. |
| WARN | Warnings. The system continues to provide services but may not as expected, or a serious error occurs and requires troubleshooting. |
| INFO | General information. Logs at this level record the current operation status of the system. |
| EDIAG | Error diagnosis information, which usually corresponds to a bug of OceanBase Database. |
| WDIAG | Warning diagnosis information indicating expected errors that OceanBase Database can tolerate. |
| TRACE | SQL statement debugging information. The number of logs at this level is related to SQL statement complexity and is irrelevant to the amount of data accessed. |
| DEBUG | Debugging information. Logs at this level record details about the operation status of the system during debugging, including the names, parameters, variables, and return values of the functions that are called. |
Notice
The methods for viewing and setting the log level described in this topic apply only to regular log files (election.log, observer.log, and rootservice.log). For WARNING log files (those with the .wf suffix), only logs at WARN level and above are always printed.
You can execute the SHOW PARAMETERS statement to query the current log level. The default log level is WDIAG.
obclient> SHOW PARAMETERS LIKE '%syslog_level%';
The return result is as follows:
+-------+----------+----------------+----------+--------------+-----------+-------+------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+---------------+-----------+
| zone | svr_type | svr_ip | svr_port | name | data_type | value | info | section | scope | source | edit_level | default_value | isdefault |
+-------+----------+----------------+----------+--------------+-----------+-------+------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+---------------+-----------+
| zone1 | observer | 172.xx.xxx.xxx | 2882 | syslog_level | NULL | WDIAG | specifies the current level of logging. There are DEBUG, TRACE, WDIAG, EDIAG, INFO, WARN, ERROR, seven different log levels. | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | WDIAG | 1 |
+-------+----------+----------------+----------+--------------+-----------+-------+------------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+---------------+-----------+
1 row in set
OceanBase Database allows you to set the log level to obtain more accurate logs. You can set the log level at three levels: system, session, and statement. When printing logs, the priority from high to low is statement, session, and system. OceanBase Database also allows you to specify the log level by module.
- System level: The scope is all OBServer nodes in the entire cluster. You can configure this level only in the sys tenant.
- Session level: The scope is the OBServer nodes where the current tenant is located in the cluster.
- A session-level variable takes effect only on the current session and not on other sessions.
- A global variable does not take effect on the current session; you need to log in again to establish a new session for it to take effect.
- Statement level: The scope is the OBServer node where the current statement is executed. The level takes effect only during SQL statement execution.
The following section describes how to set the log level at the system, session, and statement levels.
Set the 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 $pidcommand 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 thesyslog_levelvalue specified in theobserver.config.binfile in theetc/directory, and thus the kill command is invalid.Notice
We recommend that you use the
kill -41orkill -42command to adjust the log level only when you cannot log in to the OceanBase cluster from the SQL client.
Set the log generation level for the current session.
You can use the
ob_log_levelsystem parameter to set the 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 the log generation level for the current statement.
You can use a hint to set the 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.obclient > SELECT /*+log_level('sql.*:debug, common.*:info')*/ * FROM t;Note
If you want to execute SQL statements containing hints in a MySQL client, you must log in to the client by using the
-coption. Otherwise, the MySQL client will remove the hints from the SQL statements as comments, and the system cannot receive the hints.