如何访问 Redis 日志文件

在 ubuntu 服务器上安装了 Redis 和 ruby,但是不知道如何访问它的日志文件。教程说应该在这里:

/var/log/redis_6379.log

但是甚至找不到/var/文件夹

200379 次浏览

找到了:

sudo tail /var/log/redis/redis-server.log -n 100

因此,如果设置更加标准,那么应该是:

sudo tail /var/log/redis_6379.log -n 100

这将输出文件的最后100行。

您的日志文件位于您的配置中,您可以通过以下方式访问:

redis-cli CONFIG GET *

日志文件可能并不总是使用上述方法显示

tail -f `less  /etc/redis/redis.conf | grep logfile|cut -d\  -f2`

日志文件位于配置文件(通常是 /etc/redis/redis.conf)所说的位置:)

默认情况下,logfile stdout可能不是您正在寻找的。如果 redis 正在运行 daemonized,那么日志配置意味着日志将被发送到 /dev/null,即丢弃。

摘要: 在配置中设置 logfile /path/to/my/log/file.log,重写日志将写入该文件。

检查错误日志文件,然后使用 tail 命令:

tail -200f /var/log/redis_6379.log

或者

 tail -200f /var/log/redis.log

根据您的错误文件名. 。

您还可以登录到 Redis-cli 并使用 监视器命令查看针对 Redis 发生的查询。

vi /usr/local/etc/redis.conf

查找目录,日志文件

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /usr/local/var/db/redis/






# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile "redis_log"

因此,日志文件在 /usr/local/var/db/redis/redis_log创建,名称为 redis_log

您还可以尝试从 redis-cli执行 MONITOR命令来检查执行的命令数量。