如何访问Redis日志文件
在Ubuntu服务器上使用ruby设置Redis,但无法弄清楚如何访问其日志文件。教程说,这应该是在这里:如何访问Redis日志文件
/var/log/redis_6379.log
但甚至不能找到在/ var /文件夹
与发现:
sudo tail /var/log/redis/redis-server.log -n 100
因此,如果设置了更多的标准,应该是:
sudo tail /var/log/redis_6379.log -n 100
这会输出文件的最后100行。
如果你的日志文件位于在你的configs,您可以使用访问:
redis-cli CONFIG GET *
日志文件可能并不总是使用上述显示。在这种情况下使用
tail -f `less /etc/redis/redis.conf | grep logfile|cut -d\ -f2`
如果它太长时间使用'cat'来读取日志文件可能会非常糟糕(这在日志文件中发生了很多)。使用'less'或'tail'会更安全 – glarrain 2014-04-21 21:48:59
使用'*'而不是*作为*将被终端 – 2015-04-24 11:16:50
@glarrain解释你是对的。修复它 – Christoffer 2015-04-24 14:21:48
日志文件将在配置文件(通常/etc/redis/redis.conf
)说,这是:)
默认情况下,logfile stdout
这可能不是你所期待的。如果redis正在运行守护程序,那么该日志配置意味着日志将被发送到/dev/null
,即丢弃。
摘要:在您的配置文件中设置logfile /path/to/my/log/file.log
,并将redis日志写入该文件。
检查错误日志文件,然后使用tail命令:
tail -200f /var/log/redis_6379.log
或
tail -200f /var/log/redis.log
根据你的错误文件名..
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
命令查看执行的命令的数量。
你能找到你的redis使用的配置文件吗? – akonsu 2013-05-02 12:20:59
@akonsu不,也没有。我可以启动和停止它,使用redis-cli访问它,但不知道如何找到配置或日志文件。并且无法在redis.io或其他任何位置找到任何人解释它 – Christoffer 2013-05-02 12:58:22
系统上是否有'/ etc'目录?你可以运行'哪个redis-server'来找出它的安装位置? – akonsu 2013-05-02 13:35:48