Added boolean flags to mitigate log4j debugging performance.

Change-Id: Ibb481899963d75785fee0861e295d8dcdccd3289
diff --git a/full/Changes b/full/Changes
index 198ab8c..e789a76 100644
--- a/full/Changes
+++ b/full/Changes
@@ -9,7 +9,9 @@
    - Handled storing cached VC with VC reference (margaretha)
 29/11/2018
    - Added a controller for listing user clients having active refresh tokens 
-     (margaretha)  
+     (margaretha)
+6/12/2018
+   - Added debug flags to mitigate log4j debugging performance (margaretha)
    
 # version 0.61.3
 17/10/2018
diff --git a/full/src/main/java/de/ids_mannheim/korap/annotation/FreeResourceParser.java b/full/src/main/java/de/ids_mannheim/korap/annotation/FreeResourceParser.java
index 1d7bc76..a06f738 100644
--- a/full/src/main/java/de/ids_mannheim/korap/annotation/FreeResourceParser.java
+++ b/full/src/main/java/de/ids_mannheim/korap/annotation/FreeResourceParser.java
@@ -37,7 +37,7 @@
         JsonNode node = mapper.readTree(is);
         for (JsonNode resource : node) {
             String resourceId = resource.at("/id").asText();
-            log.debug(resourceId);
+//            log.debug(resourceId);
             Set<AnnotationLayer> layers = parseLayers(resource.at("/layers"));
             try {
                 Resource r = resourceDao.retrieveResource(resourceId);
diff --git a/full/src/main/java/de/ids_mannheim/korap/authentication/APIAuthentication.java b/full/src/main/java/de/ids_mannheim/korap/authentication/APIAuthentication.java
index 869b641..72378be 100644
--- a/full/src/main/java/de/ids_mannheim/korap/authentication/APIAuthentication.java
+++ b/full/src/main/java/de/ids_mannheim/korap/authentication/APIAuthentication.java
@@ -33,14 +33,14 @@
 public class APIAuthentication implements AuthenticationIface {
 
     private static Logger jlog = LogManager.getLogger(APIAuthentication.class);
-
+    public static boolean DEBUG = false;
+    
     private JWTSigner signedToken;
     private Cache invalided =
             CacheManager.getInstance().getCache("id_tokens_inv");
     // private Cache id_tokens =
     // CacheManager.getInstance().getCache("id_tokens");
 
-
     public APIAuthentication (FullConfiguration config) throws JOSEException {
         this.signedToken = new JWTSigner(config.getSharedSecret(),
                 config.getIssuer(), config.getTokenTTL());
@@ -82,7 +82,10 @@
         try {
             c.setExpirationTime(
                     jwt.getJWTClaimsSet().getExpirationTime().getTime());
-            jlog.debug(jwt.getJWTClaimsSet().getClaim(Attributes.AUTHENTICATION_TIME));
+            if (DEBUG ) {
+                jlog.debug(jwt.getJWTClaimsSet()
+                        .getClaim(Attributes.AUTHENTICATION_TIME));
+            }
             Date authTime = jwt.getJWTClaimsSet()
                     .getDateClaim(Attributes.AUTHENTICATION_TIME);
             ZonedDateTime time = ZonedDateTime.ofInstant(authTime.toInstant(),
diff --git a/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java b/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
index e4e8ac1..e6bce21 100644
--- a/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
+++ b/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
@@ -61,6 +61,8 @@
 public class KustvaktAuthenticationManager extends AuthenticationManager {
 
 	private static Logger jlog = LogManager.getLogger(KustvaktAuthenticationManager.class);
+	public static boolean DEBUG = false;
+	
 	private EncryptionIface crypto;
 	private EntityHandlerIface entHandler;
 	@Autowired
@@ -232,7 +234,11 @@
 	    {
 	    	// to be absolutely sure:
 	    	user.setCorpusAccess(User.CorpusAccess.FREE);
-	    	jlog.debug("setAccessAndLocation: DemoUser: location="+user.locationtoString()+" access="+ user.accesstoString());
+            if (DEBUG) {
+                jlog.debug("setAccessAndLocation: DemoUser: location="
+                        + user.locationtoString() + " access="
+                        + user.accesstoString());
+            }
 	     	return;
 	    }
 		
@@ -251,11 +257,17 @@
 					corpusAccess = CorpusAccess.PUB;
 				}
 				
-			    jlog.debug(String.format("X-Forwarded-For : '%s' (%d values) -> %s\n", 
-						Arrays.toString(vals), vals.length, vals[0]));
-			    jlog.debug(String.format("X-Forwarded-For : location = %s corpusAccess = %s\n",
-						location == Location.INTERN ? "INTERN" : "EXTERN", corpusAccess == CorpusAccess.ALL ? "ALL"
-								: corpusAccess == CorpusAccess.PUB ? "PUB" : "FREE"));
+				if (DEBUG){
+                    jlog.debug(String.format(
+                            "X-Forwarded-For : '%s' (%d values) -> %s\n",
+                            Arrays.toString(vals), vals.length, vals[0]));
+                    jlog.debug(String.format(
+                            "X-Forwarded-For : location = %s corpusAccess = %s\n",
+                            location == Location.INTERN ? "INTERN" : "EXTERN",
+                            corpusAccess == CorpusAccess.ALL ? "ALL"
+                                    : corpusAccess == CorpusAccess.PUB ? "PUB"
+                                            : "FREE"));
+                }
 
 			} catch (UnknownHostException e) {
 				// TODO Auto-generated catch block
@@ -265,7 +277,11 @@
 			user.setLocation(location);
 			user.setCorpusAccess(corpusAccess);
 	    	
-	    	jlog.debug("setAccessAndLocation: KorAPUser: location="+user.locationtoString()+", access="+ user.accesstoString());
+            if (DEBUG) {
+                jlog.debug("setAccessAndLocation: KorAPUser: location="
+                        + user.locationtoString() + ", access="
+                        + user.accesstoString());
+            }
 
 		}
 	} // getAccess
@@ -345,8 +361,10 @@
 		}
 
 		boolean isAdmin = adminDao.isAdmin(unknown.getUsername());
-		jlog.debug("Authentication: found username " + unknown.getUsername());
-
+        if (DEBUG) {
+            jlog.debug(
+                    "Authentication: found username " + unknown.getUsername());
+        }
 		if (unknown instanceof KorAPUser) {
 			if (password == null || password.isEmpty())
 				throw new WrappedException(new KustvaktException(unknown.getId(), StatusCodes.BAD_CREDENTIALS),
@@ -370,7 +388,10 @@
 				URIParam param = (URIParam) user.getField(URIParam.class);
 
 				if (param.hasValues()) {
-					jlog.debug("Account is not yet activated for user '"+user.getUsername()+"'" );
+                    if (DEBUG) {
+                        jlog.debug("Account is not yet activated for user '"
+                                + user.getUsername() + "'");
+                    }
 					if (TimeUtils.getNow().isAfter(param.getUriExpiration())) {
 						jlog.error("URI token is expired. Deleting account for user "+ user.getUsername());
 						deleteAccount(user);
@@ -391,7 +412,9 @@
 		} else if (unknown instanceof ShibbolethUser) {
 			// todo
 		}
-		jlog.debug("Authentication done: "+unknown);
+        if (DEBUG) {
+            jlog.debug("Authentication done: " + unknown);
+        }
 		return unknown;
 	}
 
@@ -431,7 +454,9 @@
 		try {
 			// todo: unknown = ...
 			int ret = LdapAuth3.login(username, password, config.getLdapConfig());
-			System.out.printf("Debug: autenticationIdM: Ldap.login(%s) returns: %d.\n", username, ret);
+			if (DEBUG){
+			    jlog.debug("Debug: autenticationIdM: Ldap.login(%s) returns: %d.\n", username, ret);
+			}
 			if (ret != LdapAuth3.LDAP_AUTH_ROK) {
 				jlog.error("LdapAuth3.login(username='"+username+"') returns '"+ret+"'='"+LdapAuth3.getErrMessage(ret)+"'!");
 
@@ -474,8 +499,10 @@
 		 */
 		unknown = user;
 
-		jlog.trace("Authentication: found username " + unknown.getUsername());
-
+        if (DEBUG) {
+            jlog.trace(
+                    "Authentication: found username " + unknown.getUsername());
+        }
 		if (unknown instanceof KorAPUser) {
 			/*
 			 * password already checked using LDAP: if (password == null ||
@@ -523,7 +550,9 @@
 			// todo
 		}
 
-		jlog.debug("Authentication done: " + username);
+        if (DEBUG) {
+            jlog.debug("Authentication done: " + username);
+        }
 		return unknown;
 
 	} // authenticateIdM
@@ -752,7 +781,10 @@
 
 	// todo:
 	private ShibbolethUser createShibbUserAccount(Map<String, Object> attributes) throws KustvaktException {
-		jlog.debug("creating shibboleth user account for user attr: "+ attributes);
+        if (DEBUG) {
+            jlog.debug("creating shibboleth user account for user attr: "
+                    + attributes);
+        }
 		Map<String, Object> safeMap = validator.validateMap(attributes);
 
 		// todo eppn non-unique.join with idp or use persistent_id as username
diff --git a/full/src/main/java/de/ids_mannheim/korap/authentication/LoginCounter.java b/full/src/main/java/de/ids_mannheim/korap/authentication/LoginCounter.java
index 7da50b6..aeb2856 100644
--- a/full/src/main/java/de/ids_mannheim/korap/authentication/LoginCounter.java
+++ b/full/src/main/java/de/ids_mannheim/korap/authentication/LoginCounter.java
@@ -20,9 +20,12 @@
     private final Map<String, Long[]> failedLogins;
     private KustvaktConfiguration config;
 
+    public static boolean DEBUG = false;
 
     public LoginCounter (KustvaktConfiguration config) {
-        jlog.debug("init login counter for authentication management");
+        if (DEBUG) {
+            jlog.debug("init login counter for authentication management");
+        }
         this.config = config;
         this.failedLogins = new HashMap<>();
     }
diff --git a/full/src/main/java/de/ids_mannheim/korap/authentication/SessionAuthentication.java b/full/src/main/java/de/ids_mannheim/korap/authentication/SessionAuthentication.java
index af8e953..e59d21f 100644
--- a/full/src/main/java/de/ids_mannheim/korap/authentication/SessionAuthentication.java
+++ b/full/src/main/java/de/ids_mannheim/korap/authentication/SessionAuthentication.java
@@ -29,6 +29,8 @@
 
     private static final Logger jlog = LogManager
             .getLogger(SessionAuthentication.class);
+    public static boolean DEBUG = false;
+    
     public static SessionFactory sessions;
     private ScheduledThreadPoolExecutor scheduled;
     private EncryptionIface crypto;
@@ -52,7 +54,10 @@
     @Override
     public TokenContext getTokenContext(String authenticationToken)
             throws KustvaktException {
-        jlog.debug("retrieving user session for user "+ authenticationToken);
+        if (DEBUG) {
+            jlog.debug(
+                    "retrieving user session for user " + authenticationToken);
+        }
         return this.sessions.getSession(authenticationToken);
     }
 
@@ -72,10 +77,12 @@
         ctx.setExpirationTime(ex.getMillis()+(1000));
         ctx.setHostAddress(attr.get(Attributes.HOST).toString());
         ctx.setUserAgent(attr.get(Attributes.USER_AGENT).toString());
-        jlog.debug(ctx.toJson());
         this.sessions.putSession(token, ctx);
-        jlog.debug("session " +sessions.getSession(token).toString());
-        jlog.info("create session for user: " + user.getUsername());
+        if (DEBUG) {
+            jlog.debug(ctx.toJson());
+            jlog.debug("session " +sessions.getSession(token).toString());
+            jlog.info("create session for user: " + user.getUsername());
+        }
         return ctx;
     }
 
diff --git a/full/src/main/java/de/ids_mannheim/korap/authentication/SessionFactory.java b/full/src/main/java/de/ids_mannheim/korap/authentication/SessionFactory.java
index 6d425c2..62c7442 100644
--- a/full/src/main/java/de/ids_mannheim/korap/authentication/SessionFactory.java
+++ b/full/src/main/java/de/ids_mannheim/korap/authentication/SessionFactory.java
@@ -33,6 +33,7 @@
 public class SessionFactory implements Runnable {
 
     private static Logger jlog = LogManager.getLogger(SessionFactory.class);
+    public static boolean DEBUG = false;
 
     public static ConcurrentMap<String, TokenContext> sessionsObject;
     public static ConcurrentMap<String, DateTime> timeCheck;
@@ -43,7 +44,9 @@
 
 
     public SessionFactory (boolean multipleEnabled, int inactive) {
-        jlog.debug("allow multiple sessions per user: "+ multipleEnabled);
+        if (DEBUG) {
+            jlog.debug("allow multiple sessions per user: " + multipleEnabled);
+        }
         this.multipleEnabled = multipleEnabled;
         this.inactive = inactive;
         this.sessionsObject = new ConcurrentHashMap<>();
@@ -63,7 +66,9 @@
     // todo: remove this!
     @Cacheable("session")
     public TokenContext getSession (String token) throws KustvaktException {
-        jlog.debug("logged in users: "+ loggedInRecord);
+        if (DEBUG) {
+            jlog.debug("logged in users: " + loggedInRecord);
+        }
         TokenContext context = sessionsObject.get(token);
         if (context != null) {
             // fixme: set context to respecitve expiratin interval and return context. handler checks expiration later!
@@ -134,11 +139,12 @@
         if (timeCheck.containsKey(token)) {
             if (TimeUtils.plusSeconds(timeCheck.get(token).getMillis(),
                     inactive).isAfterNow()) {
-                jlog.debug("user has session");
+                if (DEBUG){ jlog.debug("user has session");}
                 return true;
             }
-            else
+            else if (DEBUG){
                 jlog.debug("user with token "+token+" has an invalid session");
+            }
         }
         return false;
     }
@@ -161,9 +167,12 @@
             }
         }
         // fixme: not doing anything!
-        if (inactive.size() > 0)
+        if (inactive.size() > 0){
+            if (DEBUG){
             jlog.trace("removing inactive user session for users "+
                     inactive);
+            }
+        }
     }
 
 
diff --git a/full/src/main/java/de/ids_mannheim/korap/config/JWTSigner.java b/full/src/main/java/de/ids_mannheim/korap/config/JWTSigner.java
index dee393f..21f3921 100644
--- a/full/src/main/java/de/ids_mannheim/korap/config/JWTSigner.java
+++ b/full/src/main/java/de/ids_mannheim/korap/config/JWTSigner.java
@@ -39,6 +39,7 @@
 public class JWTSigner {
 
     private static Logger jlog = LogManager.getLogger(JWTSigner.class);
+    public static boolean DEBUG = false;
     
     private URL issuer;
     private JWSSigner signer;
@@ -92,7 +93,7 @@
                 attr.get(Attributes.AUTHENTICATION_TIME));
         
         JWTClaimsSet jwtClaimsSet = csBuilder.build();
-        jlog.debug(jwtClaimsSet.getClaim(Attributes.AUTHENTICATION_TIME));
+        if (DEBUG) jlog.debug(jwtClaimsSet.getClaim(Attributes.AUTHENTICATION_TIME));
         SignedJWT signedJWT =
                 new SignedJWT(new JWSHeader(JWSAlgorithm.HS256), jwtClaimsSet);
         try {
diff --git a/full/src/main/java/de/ids_mannheim/korap/config/NamedVCLoader.java b/full/src/main/java/de/ids_mannheim/korap/config/NamedVCLoader.java
index 2b72e84..f1242e5 100644
--- a/full/src/main/java/de/ids_mannheim/korap/config/NamedVCLoader.java
+++ b/full/src/main/java/de/ids_mannheim/korap/config/NamedVCLoader.java
@@ -31,7 +31,8 @@
     @Autowired
     private VirtualCorpusService vcService;
 
-    private static Logger jlog = LogManager.getLogger(NamedVCLoader.class);
+    public static Logger jlog = LogManager.getLogger(NamedVCLoader.class);
+    public static boolean DEBUG = false;
 
     public void loadVCToCache (String filename, String filePath)
             throws IOException, QueryException, KustvaktException {
@@ -71,7 +72,9 @@
                     VirtualCorpus vc = vcService.searchVCByName("system",
                             filename, "system");
                     if (vc != null) {
-                        jlog.debug("Delete existing vc: " + filename);
+                        if (DEBUG) {
+                            jlog.debug("Delete existing vc: " + filename);
+                        }
                         vcService.deleteVC("system", vc.getId());
                     }
                 }
@@ -106,7 +109,9 @@
                     + " is not allowed. Filename must ends with .jsonld or .jsonld.gz");
         }
         long end = System.currentTimeMillis();
-        jlog.debug("READ " + filename + " duration: " + (end - start));
+        if (DEBUG) {
+            jlog.debug("READ " + filename + " duration: " + (end - start));
+        }
 
         return new String[] { filename, json };
     }
@@ -118,18 +123,18 @@
         start = System.currentTimeMillis();
 
         KrillCollection collection = new KrillCollection(json);
-        jlog.debug("Finished creating KrillCollection");
-        jlog.debug("Set Index to collection");
         collection.setIndex(searchKrill.getIndex());
 
-        jlog.debug("StoreInCache " + filename);
+        jlog.info("Store vc in cache " + filename);
         if (collection != null) {
             collection.storeInCache(filename);
         }
         end = System.currentTimeMillis();
         jlog.info(filename + " caching duration: " + (end - start));
-        jlog.debug("memory cache: "
-                + KrillCollection.cache.calculateInMemorySize());
+        if (DEBUG) {
+            jlog.debug("memory cache: "
+                    + KrillCollection.cache.calculateInMemorySize());
+        }
     }
 
 }
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2AuthorizationService.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2AuthorizationService.java
index 227cf0e..4fab78a 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2AuthorizationService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2AuthorizationService.java
@@ -22,9 +22,11 @@
 @Service(value = "authorizationService")
 public class OAuth2AuthorizationService {
 
-    private static Logger jlog =
+    public static Logger jlog =
             LogManager.getLogger(OAuth2AuthorizationService.class);
 
+    public static boolean DEBUG = false;
+    
     @Autowired
     protected OAuth2ClientService clientService;
     @Autowired
@@ -179,9 +181,10 @@
     private boolean isExpired (ZonedDateTime expiryDate) {
         ZonedDateTime now =
                 ZonedDateTime.now(ZoneId.of(Attributes.DEFAULT_TIME_ZONE));
-        jlog.debug("createdDate: " + expiryDate);
-        jlog.debug("expiration: " + expiryDate + ", now: " + now);
-
+        if (DEBUG) {
+            jlog.debug("createdDate: " + expiryDate);
+            jlog.debug("expiration: " + expiryDate + ", now: " + now);
+        }
         if (expiryDate.isAfter(now)) {
             return false;
         }
diff --git a/full/src/main/java/de/ids_mannheim/korap/service/MailService.java b/full/src/main/java/de/ids_mannheim/korap/service/MailService.java
index 13a6969..1aaebc5 100644
--- a/full/src/main/java/de/ids_mannheim/korap/service/MailService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/service/MailService.java
@@ -33,8 +33,9 @@
 @Service
 public class MailService {
 
-    private static Logger jlog = LogManager.getLogger(MailService.class);
-
+    public static Logger jlog = LogManager.getLogger(MailService.class);
+    public static boolean DEBUG = false;
+    
     @Autowired
     private AuthenticationManager authenticationManager;
     @Autowired
@@ -84,7 +85,7 @@
                 StandardCharsets.UTF_8.name(), context, stringWriter);
 
         String message = stringWriter.toString();
-        jlog.debug(message);
+        if (DEBUG) jlog.debug(message);
         return message;
     }
 }
diff --git a/full/src/main/java/de/ids_mannheim/korap/service/ResourceService.java b/full/src/main/java/de/ids_mannheim/korap/service/ResourceService.java
index ed68fc9..373f42f 100644
--- a/full/src/main/java/de/ids_mannheim/korap/service/ResourceService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/service/ResourceService.java
@@ -21,7 +21,8 @@
 @Service
 public class ResourceService {
 
-    private static Logger jlog = LogManager.getLogger(ResourceService.class);
+    public static Logger jlog = LogManager.getLogger(ResourceService.class);
+    public static boolean DEBUG = false;
 
     @Autowired
     private ResourceDao resourceDao;
@@ -32,7 +33,9 @@
         List<Resource> resources = resourceDao.getAllResources();
         List<ResourceDto> resourceDtos =
                 resourceConverter.convertToResourcesDto(resources);
-        jlog.debug("/info " + resourceDtos.toString());
+        if (DEBUG) {
+            jlog.debug("/info " + resourceDtos.toString());
+        }
         return resourceDtos;
     }
 
diff --git a/full/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java b/full/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java
index 9133169..b45114d 100644
--- a/full/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/service/UserGroupService.java
@@ -44,7 +44,9 @@
 @Service
 public class UserGroupService {
 
-    private static Logger jlog = LogManager.getLogger(UserGroupService.class);
+    public static Logger jlog = LogManager.getLogger(UserGroupService.class);
+    public static boolean DEBUG = false;
+    
     @Autowired
     private UserGroupDao userGroupDao;
     @Autowired
@@ -412,10 +414,14 @@
         }
         // status pending
         else {
-            jlog.debug("status: " + member.getStatusDate());
+            if (DEBUG) {
+                jlog.debug("status: " + member.getStatusDate());
+            }
             ZonedDateTime expiration = member.getStatusDate().plusMinutes(30);
             ZonedDateTime now = ZonedDateTime.now();
-            jlog.debug("expiration: " + expiration + ", now: " + now);
+            if (DEBUG) {
+                jlog.debug("expiration: " + expiration + ", now: " + now);
+            }
 
             if (expiration.isAfter(now)) {
                 member.setStatus(GroupMemberStatus.ACTIVE);
diff --git a/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java b/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java
index 790e520..c4f2241 100644
--- a/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/service/VirtualCorpusService.java
@@ -53,9 +53,11 @@
 @Service
 public class VirtualCorpusService {
 
-    private static Logger jlog =
+    public static Logger jlog =
             LogManager.getLogger(VirtualCorpusService.class);
 
+    public static boolean DEBUG = false;
+    
     public static Pattern wordPattern = Pattern.compile("[-\\w. ]+");
 
     @Autowired
@@ -262,13 +264,16 @@
             KoralCollectionQueryBuilder koral = new KoralCollectionQueryBuilder();
             koral.with("referTo "+name);
             String vcRef = koral.toJSON();
-            jlog.debug("Determine vc access with vc ref: " + vcRef);
+            if (DEBUG) {
+                jlog.debug("Determine vc access with vc ref: " + vcRef);
+            }
             requiredAccess = determineRequiredAccess(vcRef);
         }
         else{
             requiredAccess = determineRequiredAccess(koralQuery);
         }
-        jlog.debug("Storing VC "+name);
+        
+        if (DEBUG) jlog.debug("Storing VC "+name+"in the database ");
         int vcId = 0;
         try {
             vcId = vcDao.createVirtualCorpus(name, type, requiredAccess,
@@ -308,7 +313,9 @@
             throw new KustvaktException(StatusCodes.INVALID_ARGUMENT,
                     "Invalid argument: " + corpusQuery, corpusQuery);
         }
-        jlog.debug(koralQuery);
+        if (DEBUG) {
+            jlog.debug(koralQuery);
+        }
         return koralQuery;
     }
 
@@ -336,7 +343,10 @@
         String statistics = krill.getStatistics(json);
         JsonNode node = JsonUtils.readTree(statistics);
         int numberOfDoc = node.at("/documents").asInt();
-        jlog.debug("License: " + license + ", number of docs: " + numberOfDoc);
+        if (DEBUG) {
+            jlog.debug(
+                    "License: " + license + ", number of docs: " + numberOfDoc);
+        }
         return (numberOfDoc > 0) ? true : false;
     }