Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra query logging through spring configuration

is there any easy way to turn on query logging on cassandra through xml configuration? I'm using namespace:

xmlns:cassandra="http://www.springframework.org/schema/data/cassandra"

but I can't find any suitable solution. I was trying to turn on trace through cqlsh, but it dosen't work for my app.

I was trying also to add line:

<logger name="com.datastax.driver.core.QueryLogger.NORMAL" level="TRACE" />

But also doesn't work.

My versions: spring-data-cassandra-1.4.0 cassandra: 2.1.5

like image 777
Marcin Erbel Avatar asked Nov 30 '22 15:11

Marcin Erbel


1 Answers

Add a QueryLogger @Bean and get the Cluster @Autowired in:

@Bean
public QueryLogger queryLogger(Cluster cluster) {
    QueryLogger queryLogger = QueryLogger.builder()
            .build();
    cluster.register(queryLogger);
    return queryLogger;
}

(+ obviously configure QueryLogger.Builder as required).

Don't forget to set log levels to DEBUG/TRACE in your application.yml:

logging.level.com.datastax.driver.core.QueryLogger.NORMAL: DEBUG
logging.level.com.datastax.driver.core.QueryLogger.SLOW: TRACE

Voilà!

like image 131
Hartmut Avatar answered Dec 05 '22 10:12

Hartmut