Logs are automatically generated during the running of OceanBase Database. By viewing and analyzing these logs, O&M engineers can understand the startup and operation status of OceanBase Database. This topic describes the basic information about logs, including the log types, log levels, log formats, and log file sizes. This topic also describes how to view logs.
Log module types
Program logs involve two levels of modules: parent modules and submodules.
OceanBase Database provides the following parent modules: CLIENT, CLOG, COMMON, ELECT, LIB, PROXY, RPC, RS, SERVER, SHARE, SQL, STORAGE, and TLOG. If a parent module contains a submodule, the submodule is expressed in the Parent module.Submodule format. For example, in the expression of SQL.PARSER, SQL indicates the SQL module, and SQL.PARSER indicates the PARSER submodule under the SQL module. SQL.* indicates all submodules under the SQL module.
Log file types
OceanBase Database has three types of log files: observer.log, election.log, and rootservice.log. By default, these log files record logs at or above the INFO level. A WARNING log file with the .wf file name extension is automatically generated for each type of log file: observer.log.wf, election.log.wf, and rootservice.log.wf. These WARNING log files record logs at or above the WARN level.
| Log | Path |
|---|---|
Startup and operation logs: observer.log and observer.log.wf |
~/appname/log directory of an OBServer node |
Election module logs: election.log and election.log.wf |
~/appname/log directory of an OBServer node |
RootService logs: rootservice.log and rootservice.log.wf |
~/appname/log directory of an OBServer node |
Log levels
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. |
| USER_ERROR | Errors caused by user input. |
| WARN | Warnings. Logs at this level record potential errors that may occur. |
| 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. |
Log formats
OceanBase Database adopts the following log formats:
[time] log_level [module_name] (file_name:fine_no) [thread_id][Y_trace_id0-trace_id1] [lt=last_log_print_time] [dc=dropped_log_count] log_data_[time] log_level [module_name] function_name (file_name:fine_no) [thread_id][Y_trace_id0-trace_id1] [lt=last_log_print_time] [dc=] log_data_
Sample logs:
[admin@OceanBase000000000.sqa.ztt /home/admin/oceanbase/log]
$tail -f -n 1 observer.log
[2016-07-17 14:18:04.845802] INFO [RPC.OBMYSQL] obsm_handler.cpp:191 [9543][Y0-0] [lt=47] [dc=0] connection close(easy_connection_str(c)="192.168.0.2:56854_-1_0x7fb8a9171b68", version=0, sessid=2147562562, tenant_id=1, server_id=1, is_need_clear_sessid_=true, ret=0)
[admin@OceanBase000000000.sqa.ztt /home/admin/oceanbase/log]
$tail -f -n 1 observer.log.wf
[2016-07-17 14:18:28.431351] WARN [SQL.SESSION] set_conn (ob_basic_session_info.cpp:2568) [8541][YB420AF4005E-52A8CF4E] [lt=16] [dc=0] debug for set_conn(conn=0x7fb8a9171b68, lbt()="0x4efe71 0x818afd 0xe9ea5b 0x721fc8 0x13747bc 0x2636db0 0x2637d68 0x5054e9 0x7fb98705aaa1 0x7fb9852cc93d ", magic_num_=324478056, sessid_=2147562617, version_=0)
[admin@OceanBase000000000.sqa.ztt /home/admin/oceanbase/log]
$tail -f -n 1 rootservice.log
[2016-07-17 14:18:53.701463] INFO [RS] ob_server_table_operator.cpp:345 [8564][Y0-0] [lt=11] [dc=0] svr_status(svr_status="active", display_status=1)
[admin@OceanBase000000000.sqa.ztt /home/admin/oceanbase/log]
$tail -f -n 1 rootservice.log.wf
[2016-07-16 02:02:12.847602] WARN [RS] choose_leader (ob_leader_coordinator.cpp:2067) [8570][YB420AF4005E-4626EDFC] [lt=8] [dc=0] choose leader info with not same candidate num(tenant_id=1005, server="192.168.0.1:2882", info={original_leader_count:0, primary_zone_count:0, cur_leader_count:1, candidate_count:1, in_normal_unit_count:1})
The following table describes the parameters in logs.
| Parameter | Description |
|---|---|
| time | The time when the log was generated. |
| log_level | The level of the log. |
| module_name | The module that contains the statement corresponding to the log. For more information about log modules, see [Log module types](#Log module types). |
| function_name | The function that contains the statement corresponding to the log. |
| file_name | The file that contains the statement corresponding to the log. |
| file_no | The row number of the statement corresponding to the log. |
| thread_id | The ID of the thread corresponding to the log. |
| trace_id0-trace_id1 | The trace_id value of the log, which consists of trace_id0 and trace_id1. A trace_id value can be transmitted between OBServer nodes through remote procedure calls (RPCs). Therefore, you can obtain associated logs of OBServer nodes based on trace_id values. |
| last_log_print_time | OBServer nodes support synchronous and asynchronous logs. When synchronous logs are enabled, this parameter indicates the amount of time spent on recording the previous log. When asynchronous logs are enabled, this parameter indicates the amount of time spent on formatting the current log. |
| dropped_log_count | The number of dropped logs. |
| log_data | The detailed log data. |
Procedure
Perform the following steps to view logs in OceanBase Database.
Log on to the required OBServer node.
Run the following command to enter the directory where log files are located:
su - admin cd /home/admin/oceanbase/logRun the following command to view the logs that have been written to the required log file:
more observer.logRun the following command to view the logs that are being written to the log file:
tail observer.log
More information
For more information about log modules, see Overview of logs.