Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to log/trace redis calls from java spring app

I'm looking for the simplest way to log the redis activity originating from my java springboot microservice (queries and responses).

I want to see (in the main springboot log file) log lines whenever data is extracted/inserted from/to redis.

My code use the typical spingframework data redis approach like this:

import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.redis.core.TimeToLive;

@RedisHash
public class InternalAddress {
    private String county;
    private String postcode;
    @TimeToLive
    private Long expiry;
}

*

import org.springframework.data.repository.CrudRepository;

public interface AddressRepository extends CrudRepository<InternalAddress, String> {}

I tried to enable some logging like this.

logging:
  level:
    root: INFO
    redis.clients: TRACE
    org.springframework.data: TRACE

but what i get is totally useless to me: either nothing or just some info about connections being opened or closed...

what i want to see in my log is this really:

2017-11-28T16:05:18.140+00:00 HGETALL key5645 => {...returned data...}
2017-11-28T16:05:25.140+00:00 LPUSH whatever
2017-11-28T16:05:25.140+00:00 HMSET blahblahblah

Any idea? did i miss the right class i should be tracing?

Is there some custom interceptor/listener/aop code i need to write?

Any other approach? Thanks in advance

like image 746
MikaelW Avatar asked Nov 28 '17 16:11

MikaelW


1 Answers

There's no logging available right now. You could implement something yourself but you'd need to augment connection factories with AOP which can be a bit of work. I filed a ticket to address your issue.

Have you tried using Redis' MONITOR command?

like image 163
mp911de Avatar answered Nov 11 '22 05:11

mp911de