Log Commands

LIST LOG

The LIST LOG command is used to retrieve the logs generated on server side. Logs can contain a huge number of entries. That’s the reason why this command has so many filter options. The FROM/TO dates restrict the query to a specific date range.

The LEVEL integer argument specifies the log details we are interested in. Possible options are:

  • LOG_LEVEL_PANIC = 0 (used in Raft)
  • LOG_LEVEL_FATAL = 1
  • LOG_LEVEL_ERROR = 2
  • LOG_LEVEL_WARNING = 3
  • LOG_LEVEL_INFO = 4
  • LOG_LEVEL_DEBUG = 5

The TYPE integer argument should specify the log type we are interested in. Possible values are:

  • LOG_TYPE_INTERNAL = 1, // internally generated by the server
  • LOG_TYPE_SECURITY = 2, // security issues
  • LOG_TYPE_SQL = 3, // log all SQL commands
  • LOG_TYPE_COMMAND = 4, // log all built-in commands
  • LOG_TYPE_RAFT = 5, // log related to Raft
  • LOG_TYPE_CLUSTER = 6, // log related to Cluster
  • LOG_TYPE_PLUGIN = 7, // log generated by a plugin
  • LOG_TYPE_CLIENT = 8 // log related to a client

The ID option instructs the rowset to add the unique ID column to the rowset. The LIMIT option sets a maximum number of rows to return. The CURSOR option is used to paginate and navigate the rowset. The NODE argument forces the execution of the command to a specific node of the cluster.

Syntax

LIST LOG [FROM start_date] [TO end_date] [LEVEL log_level] [TYPE log_type] [ID] [LIMIT count] [CURSOR cursorid] [NODE nodeid]

Privileges

HOSTADMIN

Return

A Rowset with the following columns: datetime, log_type, log_level, description, username, database, ip_address, connection_id`.

A Rowset with the following columns:

  • datetime: log entry date and time
  • log_type: log type (a number from 1 to 8, see description)
  • log_level: log level (a number from 0 to 5, see description)
  • description: a textual description of the event
  • username: the username associated to the entry
  • database: the database name (if any) bound to the event
  • ip_address: the origin IP address
  • connection_id: the unique connection ID

Example

> LIST LOG LIMIT 10
---------------------|----------|-----------|-------------------------------------------------|----------|----------|------------|---------------|
 datetime            | log_type | log_level | description                                     | username | database | ip_address | connection_id |
---------------------|----------|-----------|-------------------------------------------------|----------|----------|------------|---------------|
 2023-02-09 15:46:14 | 4        | 4         | LIST LOG LIMIT 10                               | admin    | NULL     | 127.0.0.1  | 1             |
 2023-02-09 15:46:10 | 8        | 2         | 10002 Unable to find command LIST LOGS LIMIT 1  | admin    | NULL     | 127.0.0.1  | 1             |
 2023-02-09 15:46:04 | 8        | 2         | 10002 Unable to find command LIST LOGS LIMIT 10 | admin    | NULL     | 127.0.0.1  | 1             |
 2023-02-09 15:45:58 | 8        | 2         | 10002 Unable to find command LIST LOGS LIMIT 10 | admin    | NULL     | 127.0.0.1  | 1             |
 2023-02-09 15:34:40 | 4        | 4         | LIST USERS WITH ROLES                           | admin    | NULL     | 127.0.0.1  | 1             |
 2023-02-09 15:34:26 | 4        | 4         | LIST USERS                                      | admin    | NULL     | 127.0.0.1  | 1             |
 2023-02-09 15:04:38 | 4        | 4         | LIST ALLOWED IP                                 | admin    | NULL     | 127.0.0.1  | 1             |
 2023-02-09 14:56:15 | 4        | 4         | LIST ONLY RESERVED COMMANDS                     | admin    | NULL     | 127.0.0.1  | 1             |
 2023-02-09 14:56:05 | 4        | 4         | SET CLIENT KEY COMPRESSION TO 1;                | admin    | NULL     | 127.0.0.1  | 1             |
 2023-02-09 14:56:05 | 4        | 4         | AUTH USER admin PASSWORD *****                  | NULL     | NULL     | 127.0.0.1  | 1             |
---------------------|----------|-----------|-------------------------------------------------|----------|----------|------------|---------------|