78

Have Redis setup with ruby on ubuntu server, but can't figure out how to access its log file. Tutorial says it should be here:

/var/log/redis_6379.log

But can't even find the /var/ folder

halfer
  • 19,824
  • 17
  • 99
  • 186
Christoffer
  • 7,436
  • 4
  • 40
  • 42
  • can you find the config file that your redis uses? – akonsu May 02 '13 at 12:20
  • @akonsu No not that either. I can start and stop it, access it with redis-cli, but no idea how to find the config or log file. And can't find anyone explaining it neither on redis.io or anywhere else – Christoffer May 02 '13 at 12:58
  • is there `/etc` directory on your system? can you run `which redis-server` to find out where it is installed? – akonsu May 02 '13 at 13:35
  • @akonsu found it another way. Still don't know how to "cd" my way to it though – Christoffer May 02 '13 at 14:10
  • You can also use: `locate *redis*log` to quickly find an existing installation. If you just installed it, you may need to run `updatedb` first, which may turn out to be slower than looking over conf :) – dhaupin May 30 '17 at 20:49

6 Answers6

84

Found it with:

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

So if the setup was more standard that should be:

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

This outputs the last 100 lines of the file.

Where your log file is located is in your configs that you can access with:

redis-cli CONFIG GET *

The log file may not always be shown using the above. In that case use

tail -f `less  /etc/redis/redis.conf | grep logfile|cut -d\  -f2`
Christoffer
  • 7,436
  • 4
  • 40
  • 42
  • 10
    Using `cat` to read a log file can be a very bad if it is too long (which happens a lot in log files). Using `less` or `tail` will be safer – glarrain Apr 21 '14 at 21:48
  • 2
    use '*' instead of * as * would be interpreted by terminal – Sarath Sadasivan Pillai Apr 24 '15 at 11:16
  • 4
    This is a known, but someone may find it useful: When looking for signs of crash/issues, Redis log may not help much...it may just show normal op then service online messages. So check the webserver (apache?) error log, logs for handlers such as FCGI, and in the syslog for proc kills or other alerts. Also check any tracked/historical resource useage (like Cloudlinux or newrelic graphs) in order to have insight for future -- example, a massive nightly MySQL backup happening at the same time as an SEO crawler speeding the entire site (gen all cache) may cause destruction, redis out of mem, etc – dhaupin Jan 05 '16 at 15:46
  • user is redis and group is also redis can't run cd /var/log/redis – anurag2201 Apr 24 '20 at 14:48
41

You can also login to the redis-cli and use the MONITOR command to see what queries are happening against Redis.

blimmer
  • 2,038
  • 20
  • 23
  • 1
    You saved my day. My use-case was to start Redis-docker and from inside the container I needed to run a script to populate the sample data. But after running docker-server in the background, and injecting data, the container was exiting. So at the end after all my commands I added the Redis-CLI monitor and it worked. Thanks. – Vikram Ray Nov 19 '20 at 06:11
16
vi /usr/local/etc/redis.conf

Look for dir, logfile

# 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"

So the log file is created at /usr/local/var/db/redis/redis_log with the name redis_log

You can also try MONITOR command from redis-cli to review the number of commands executed.

Kanagavelu Sugumar
  • 18,766
  • 20
  • 94
  • 101
  • 1
    even after changing the `conf` file and running ther redis-server again & doing some oeprations, I couldn't fine the log at this dir `/usr/local/var/db/redis/`, the `dir` is still empty. – Amit Upadhyay Sep 13 '19 at 05:50
13

The log file will be where the configuration file (usually /etc/redis/redis.conf) says it is :)

By default, logfile stdout which probably isn't what you are looking for. If redis is running daemonized, then that log configuration means logs will be sent to /dev/null, i.e. discarded.

Summary: set logfile /path/to/my/log/file.log in your config and redis logs will be written to that file.

glarrain
  • 8,031
  • 7
  • 31
  • 44
4

I recommend you to use redis-cli monitoring tool. Simple type the following command:

redis-cli monitor

It gives you a real-time access log which helps you troubleshoot the problems and...

Hamid Haghdoost
  • 740
  • 1
  • 6
  • 15
-1

Check your error log file and then use the tail command as:

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

or

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

According to your error file name..

Aman Aggarwal
  • 17,619
  • 9
  • 53
  • 81