OceanBase Database supports six log levels. The following table describes the log levels in descending order.
| Log level | Description |
|---|---|
| ERROR | Critical errors: unexpected errors, unrecoverable errors, and errors that require manual intervention. |
| USER_ERROR | Errors caused by user input. |
| WARN | Warnings for exceptions that are expected and can be resolved by the program. |
| INFO | General information. Logs at this level record the current operation status of the system. |
| TRACE | More detailed event information compared with logs at the INFO level. |
| 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 recording level. By default, INFO logs are recorded.
obclient> SHOW PARAMETERS LIKE '%syslog_level%';
+-------+----------+-----------------+----------+--------------+-----------+-------+------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
| zone | svr_type | svr_ip | svr_port | name | data_type | value | info | section | scope | source | edit_level |
+-------+----------+-----------------+----------+--------------+-----------+-------+------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
| zone1 | observer | XXX.XXX.XXX.XXX | 2882 | syslog_level | NULL | INFO | specifies the current level of logging. There are DEBUG, TRACE, INFO, WARN, USER_ERR, ERROR, six different log levels. | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
+-------+----------+-----------------+----------+--------------+-----------+-------+------------------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+
1 row in set (0.01 sec)
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.
- System level: The log generation level set for the entire system takes effect on all OBServer nodes in the current cluster. You can set this level only under the
systenant. - Session level: The log generation level set for the current session takes effect on the OBServer node 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.
- Statement level: The log generation level set for the current statement takes effect on 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 levels.
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 $pidcommand in the operating system.In the command,
kill -41is used to lower the level of application logs. For example, the current level of application logs is INFO. The log level is lowered to TRACE after you run thekill -41command.kill -42is used to raise the level of application logs. For example, the current level of application logs is INFO. The log level is escalated 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 on to the OceanBase cluster from the SQL client.
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.obclient > SELECT /*+log_level('sql.*:debug, common.*:info')*/ * FROM t;Note
If you want to execute SQL statements containing hints on a MySQL client, you must log on 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.