Skip to content

Commit

Permalink
support for LoggingFIlter
Browse files Browse the repository at this point in the history
If system property org.neo4j.rest.logging_filter is set to true, verbose request/response logging using Jersey's com.sun.jersey.api.client.filter.LoggingFilter is enabled.
  • Loading branch information
sarmbruster committed Sep 5, 2012
1 parent b77fda7 commit 4fb2b1a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -71,5 +71,4 @@ _timeouts in seconds_
* org.neo4j.rest.driver="neo4j-rest-graphdb/1.8M07"
* org.neo4j.rest.stream=true
* org.neo4j.rest.batch_transactions=true (convert transaction scope into batch-rest-operations)


* org.neo4j.rest.logging_filter=false (set to true if verbose request/response logging should be enabled)
Expand Up @@ -27,6 +27,7 @@

import javax.ws.rs.core.MediaType;

import com.sun.jersey.api.client.filter.LoggingFilter;
import org.neo4j.helpers.collection.MapUtil;
import org.neo4j.rest.graphdb.util.Config;
import org.neo4j.rest.graphdb.util.JsonHelper;
Expand Down Expand Up @@ -69,6 +70,9 @@ protected Client createClient() {
client.setReadTimeout(Config.getReadTimeout());
client.setChunkedEncodingSize(8*1024);
userAgent.install(client);
if (Config.useLoggingFilter()) {
client.addFilter(new LoggingFilter());
}
return client;
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/neo4j/rest/graphdb/util/Config.java
Expand Up @@ -25,6 +25,7 @@ public class Config {
public final static String CONFIG_PREFIX = "org.neo4j.rest.";
public static final String CONFIG_STREAM = CONFIG_PREFIX + "stream";
public static final String CONFIG_BATCH_TRANSACTION = CONFIG_PREFIX+"batch_transaction";
public static final String CONFIG_LOG_REQUESTS = CONFIG_PREFIX+"logging_filter";

public static int getConnectTimeout() {
return getTimeout("connect_timeout", 30);
Expand All @@ -42,6 +43,10 @@ public static boolean useBatchTransactions() {
return System.getProperty(CONFIG_BATCH_TRANSACTION,"true").equalsIgnoreCase("true");
}

public static boolean useLoggingFilter() {
return System.getProperty(CONFIG_LOG_REQUESTS,"false").equalsIgnoreCase("true");
}

private static int getTimeout(final String param, final int defaultValue) {
return (int) TimeUnit.SECONDS.toMillis(Integer.parseInt(System.getProperty(CONFIG_PREFIX + param, "" + defaultValue)));
}
Expand Down

0 comments on commit 4fb2b1a

Please sign in to comment.