67

在 ubuntu 服务器上使用 ruby​​ 设置 Redis,但无法弄清楚如何访问其日志文件。教程说它应该在这里:

/var/log/redis_6379.log

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

4

5 回答 5

75

找到它:

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`
于 2013-05-02T14:09:17.730 回答
33

您还可以登录 redis-cli 并使用MONITOR命令查看针对 Redis 发生的查询。

于 2016-02-04T17:43:03.507 回答
12

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

默认情况下,logfile stdout这可能不是您想要的。如果 redis 运行的是守护进程,那么该日志配置意味着日志将被发送到/dev/null,即丢弃。

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

于 2013-07-17T18:30:18.403 回答
12
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

您还可以尝试MONITORcommand fromredis-cli查看执行的命令数。

于 2017-05-02T19:05:35.367 回答
-1

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

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

或者

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

根据你的错误文件名..

于 2015-06-23T07:02:21.343 回答