APEXCORE-761 added the utility method to read the system properties
diff --git a/common/src/main/java/org/apache/apex/common/util/PropertiesHelper.java b/common/src/main/java/org/apache/apex/common/util/PropertiesHelper.java
new file mode 100644
index 0000000..aa3d499
--- /dev/null
+++ b/common/src/main/java/org/apache/apex/common/util/PropertiesHelper.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.apex.common.util;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.hadoop.classification.InterfaceStability.Evolving;
+
+@Evolving
+public class PropertiesHelper
+{
+  /**
+   * Reading system property as long value.
+   * @param propertyName Name of the system property
+   * @param defaultValue Default value to return in case of an error, out of range etc.
+   * @param minValue minimum valid value
+   * @param maxValue maximum valid value
+   * @return returns the value if it is between min and max value(inclusive), otherwise default value is returned.
+   */
+  public static long getLong(String propertyName, long defaultValue, long minValue, long maxValue)
+  {
+    String property = System.getProperty(propertyName);
+    long result = defaultValue;
+    if (property != null) {
+      try {
+        long value = Long.decode(property);
+        if (value < minValue || value > maxValue) {
+          logger.warn("Property {} is outside the range [{},{}], setting to default {}", propertyName, minValue, maxValue, defaultValue);
+        } else {
+          result = value;
+        }
+      } catch (Exception ex) {
+        logger.warn("Can't convert property {} value {} to a long, using default {}", propertyName, property, defaultValue, ex);
+      }
+    }
+    logger.debug("System property {}'s value is {}", propertyName, result);
+
+    return result;
+  }
+
+  private static final Logger logger = LoggerFactory.getLogger(PropertiesHelper.class);
+}
diff --git a/common/src/test/java/org/apache/apex/common/util/PropertiesHelperTest.java b/common/src/test/java/org/apache/apex/common/util/PropertiesHelperTest.java
new file mode 100644
index 0000000..768b249
--- /dev/null
+++ b/common/src/test/java/org/apache/apex/common/util/PropertiesHelperTest.java
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.apex.common.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PropertiesHelperTest
+{
+  @Test
+  public void getSystemPropertyAsLongTest() throws Exception
+  {
+    String property = "org.apache.apex.com.util.systemHelper";
+    System.setProperty(property, "1001");
+
+    Assert.assertEquals(1001, PropertiesHelper.getLong(property, 100, 100, 2000));
+    Assert.assertEquals(2000, PropertiesHelper.getLong(property, 2000, 2000, 20000));
+
+    System.setProperty(property, "INVALID");
+    Assert.assertEquals(2000, PropertiesHelper.getLong(property, 2000, 2000, 20000));
+  }
+}
diff --git a/engine/src/main/java/com/datatorrent/stram/debug/TupleRecorder.java b/engine/src/main/java/com/datatorrent/stram/debug/TupleRecorder.java
index 4f6bbfa..d36aaca 100644
--- a/engine/src/main/java/com/datatorrent/stram/debug/TupleRecorder.java
+++ b/engine/src/main/java/com/datatorrent/stram/debug/TupleRecorder.java
@@ -36,6 +36,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.apex.common.util.PropertiesHelper;
+
 import com.datatorrent.api.Operator;
 import com.datatorrent.api.Sink;
 import com.datatorrent.api.Stats;
@@ -83,27 +85,9 @@
   // If there are errors processing tuples, don't log an error for every tuple as it could overwhelm the logs.
   // The property specifies the minumum number of tuples between two consecutive error log statements. Set it to zero to
   // log every tuple error
-  private static long ERROR_LOG_GAP;
+  private static long ERROR_LOG_GAP = PropertiesHelper.getLong("org.apache.apex.stram.tupleRecorder.errorLogGap", 10000L, 0, Long.MAX_VALUE);
   long lastLog = -1;
 
-  static {
-    ERROR_LOG_GAP = 10000L;
-    String property = System.getProperty("org.apache.apex.stram.tupleRecorder.errorLogGap");
-    if (property != null) {
-      try {
-        long value = Long.decode(property);
-        if (value < 0 ) {
-          logger.warn("Log gap should be greater than or equal to 0, setting to default");
-        } else {
-          ERROR_LOG_GAP = value;
-        }
-      } catch (Exception ex) {
-        logger.warn("Unable to parse the log gap property, setting to default", ex);
-      }
-    }
-    logger.debug("Log gap is {}", ERROR_LOG_GAP);
-  }
-
   private final FSPartFileCollection storage = new FSPartFileCollection()
   {
     @Override