container/src/main/java/org/cloudera/log4j/redactor/StringRedactor.java
public static StringRedactor createFromJsonFile(String fileName)
          throws IOException {
    StringRedactor sr = new StringRedactor();
    if (fileName == null) {
      sr.policy = RedactionPolicy.emptyRedactionPolicy();
      return sr;
    }
    File file = new File(fileName);
    // An empty file is explicitly allowed as "no rules"
    if (file.exists() && file.length() == 0) {
      sr.policy = RedactionPolicy.emptyRedactionPolicy();
      return sr;
    }

    ObjectMapper mapper = new ObjectMapper();
    RedactionPolicy policy = mapper.readValue(file, RedactionPolicy.class);
    policy.postProcess();
    sr.policy = policy;
    return sr;
  }
public static StringRedactor createFromJsonFile(String fileName)
          throws IOException {
    StringRedactor sr = new StringRedactor();
    if (fileName == null) {
      sr.policy = RedactionPolicy.emptyRedactionPolicy();
      return sr;
    }
    File file = new File(fileName);
    // An empty file is explicitly allowed as "no rules"
    if (file.exists() && file.length() == 0) {
      sr.policy = RedactionPolicy.emptyRedactionPolicy();
      return sr;
    }

    ObjectMapper mapper = new ObjectMapper();
    RedactionPolicy policy = mapper.readValue(file, RedactionPolicy.class);
    policy.postProcess();
    sr.policy = policy;
    return sr;
  }
Create a StringRedactor based on the JSON found in a file. The file
format looks like this:
{
"version": 1,
"rules": [
{ "description": "This is the first rule",
"trigger": "triggerstring 1",
"search": "regex 1",
"replace": "replace 1"
},
{ "description": "This is the second rule",
"trigger": "triggerstring 2",
"search": "regex 2",
"replace": "replace 2"
}
]
}
@param fileName The name of the file to read
@return A freshly allocated StringRedactor
@throws JsonParseException, JsonMappingException, IOException