Log levels

2024-03-05 01:54:26  Updated

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 recording level. By default, WDIAG logs are recorded.

obclient> SHOW PARAMETERS LIKE '%syslog_level%';

The 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-logon.
  • 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 a log generation level for the entire system.

    You can use one of the following methods:

    • Use the syslog_level system parameter. For example, you can set the log generation level of the SQL module to DEBUG and that of the COMMON module to ERROR.

      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 -41 is used to lower the level of program logs. For example, the current level of application logs is INFO. The log level is lowered to TRACE after you run the kill -41 command. kill -42 is 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 the kill -42 command.

      We recommend that you use the syslog_level system parameter. This is because when OceanBase Database refreshes configurations, it loads the syslog_level value specified in the observer.config.bin file in the etc/ directory, and thus the kill command is invalid.

      Notice

      We recommend that you use the kill -41 or kill -42 command 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_level system parameter to set a log generation level. For example, you can set the log generation level of the SQL module to DEBUG and that of the COMMON module to INFO.

    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 DEBUG and that of the COMMON module to INFO. 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 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.

Contact Us