17

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

2 Answers 2

9

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?

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, in the end, i'm going down the AOP route and i have some special code to separate Redis repository calls from let's say Oracle repository calls. It also means what i get is much higher level. things like java method public void delete(String id) or public T findOne(String id).
@mp911de I see the ticket is resolved. Do we have a document? Which version of Data Redis now supports logging?
The ticket is closed as “won’t fix”. Why?
Because there's no simple way to introduce command logging from Spring Data Redis.
3

in application.yml/properties file just include below and you could see some related logs

logging:
  level:
    org.springframework.data.*.*: trace
    org.springframework.cache.*: trace

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.