Skip to content

Commit

Permalink
Add a query logger to the Cassandra storage, for debugging and profil…
Browse files Browse the repository at this point in the history
…ing. (#93)

Example of logging queries to a separate file found in cassandra-reaper-cassandra.yaml

ref: #85
  • Loading branch information
michaelsembwever authored and adejanovski committed May 10, 2017
1 parent 019dd8b commit 43ccdab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions resource/cassandra-reaper-cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ jmxPorts:
logging:
level: INFO
loggers:
com.datastax.driver.core.QueryLogger.NORMAL:
level: DEBUG
additive: false
appenders:
- type: file
currentLogFilename: query-logger.log
archivedLogFilenamePattern: query-logger-%d.log.gz
archivedFileCount: 2
io.dropwizard: WARN
org.eclipse.jetty: WARN
appenders:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.datastax.driver.core.BatchStatement;
import com.datastax.driver.core.CodecRegistry;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.QueryLogger;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.ResultSetFuture;
import com.datastax.driver.core.Row;
Expand Down Expand Up @@ -96,7 +97,7 @@ public class CassandraStorage implements IStorage {
private PreparedStatement updateRepairId;

public CassandraStorage(ReaperApplicationConfiguration config, Environment environment) {
cassandra = config.getCassandraFactory().build(environment);
cassandra = config.getCassandraFactory().build(environment).register(QueryLogger.builder().build());
CodecRegistry codecRegistry = cassandra.getConfiguration().getCodecRegistry();
codecRegistry.register(new DateTimeCodec());
session = cassandra.connect(config.getCassandraFactory().getKeyspace());
Expand Down

0 comments on commit 43ccdab

Please sign in to comment.