Updated on 2025-03-28 GMT+08:00

Redis Logs

Redis logs record Redis server running statuses, related events, and commands executed on clients. They include system logs and slow query logs.

  1. System logs:
    • These logs record system-level events such as Redis server startup, shutdown, configuration loading, and persistency operations, such as Redis Database (RDB) and Append Only File (AOF).
    • Redis system log levels include debug, verbose, notice, warning, and error. You can set a log level by setting the loglevel parameter in the redis.conf configuration file.
    • The output mode of system logs can be stdout (standard output) or file (file output). Use the logfile parameter in the configuration file to specify the log file path.
  2. Slow query logs:
    • These logs record the commands whose execution time exceeds the specified threshold. This helps identify bottlenecks and optimize performance.
    • You can set the slowlog-log-slower-than parameter in redis.conf to set the threshold of slow query logs, in microseconds.
    • You can use the slowlog-max-len parameter to set the maximum length of a slow query log (that is, the number of slow query records that can be saved).
    • Slow query logs are stored in the memory and are not written to disk files. However, you can run the SLOWLOG command to check and obtain slow query logs.

Collection Method

Install ICAgent and configure ECS text log ingestion by referring to Installing ICAgent (Intra-Region Hosts) and Ingesting ECS Text Logs to LTS. Then, ICAgent will collect ECS text logs and report them to LTS.

Redis Log Examples and Fields

  1. System log
    [12345] 2024-04-30 15:30:00.123456 [info] # Server started, Redis version 6.x.x  
    [12345] 2024-04-30 15:30:15.654321 [notice] * 1 client connected (IP: 127.0.0.1,port: 6379)  
    [12345] 2024-04-30 15:30:30.987654 [warning] # There are 100 clients waiting in the background, you may need to check your latency.  
    [12345] 2024-04-30 15:31:00.000000 [debug] * DB saved on disk  
    [12345] 2024-04-30 15:32:00.000000 [error] # OOM command not allowed when used memory > 'maxmemory'.
    Table 1 System log fields

    Field

    Description

    Example

    PID

    Redis server process ID (PID), which is used to identify and manage Redis processes at the system level.

    [12345]

    Timestamp

    Timestamp of the log entry, including the date, time, and millisecond.

    2024-04-30 15:30:00.123456

    Log level

    Redis uses the following log levels to indicate the importance of log entries:

    • [info]: informational message, which is usually a notification indicating that the server is running properly.
    • [notice]: notification message, indicating an important but not urgent event.
    • [warning]: warning message, indicating that a problem may occur but has not caused faults.
    • [debug]: debugging message, which is usually used for debugging and troubleshooting.
    • [error]: error message, indicating that an error or exception occurs.

    [info]

    Log content

    Describes a specific event or operation that occurs. For example, Server started indicates that the Redis server has been started, 1 client connected indicates that a client is connected to the Redis server, and OOM command not allowed indicates that Redis refuses to execute a command because the maximum memory limit is exceeded.

    Server started, Redis version 6.x.x

    Additional information

    Some log entries may contain additional information about events. For example, the 1 client connected entry includes the IP address and the port number of the connected client.

    IP: 127.0.0.1,port: 637

  2. Slow query log
    1) 1) (integer) 12345  
       2) (integer) 1598765432  
       3) (integer) 123456  
       4) 1) "GET"  
          2) "somekey"
    Table 2 System log fields

    Field

    Description

    Example

    Unique identifier

    Unique identifier of the slow query log entry. As time goes by, Redis continues to add sequence numbers to new slow query log entries.

    (integer) 12345

    Timestamp

    Timestamp when the slow query log is generated, which is usually a Unix timestamp (in seconds).

    (integer) 1598765432

    Execution duration

    Duration to execute the slow query command, in microsecond (μs).

    (integer) 123456

    Command and parameter

    • "GET": the command that is recorded as the slow query.
    • "somekey": the parameter of the GET command, that is, the key to be retrieved.

    -

Log Location

You can use the logfile configuration item in the Redis configuration file redis.conf to specify the log file path. Example:

logfile "/var/log/redis/redis-server.log"