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 apply only to the election.log, observer.log, and rootservice.log files. Logs at or above the WARN level are recorded only in log files with the .wf extension.
You can execute the SHOW PARAMETERS statement to query the current log level. By default, WDIAG logs are recorded.
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 priority of logs to statement, session, and system levels, from high to low. OceanBase Database also allows you to specify the log level by module.
- The log generation level set for the entire system takes effect for all OBServer nodes in the current cluster. You can set this level only in the sys tenant.
- The log generation level set for the current session takes effect for the OBServer node where the current tenant is located.
- A session-level 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-login.
- The log generation level set for the current statement takes effect for the OBServer node 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 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.