Log4jTextReader extends FormattedTextReader { @Override public LinkedHashMap<String, FieldBaseTypes> getFieldTypes() throws FormatException { init(); final LinkedHashMap<String, FieldBaseTypes> types = super.getFieldTypes(); if (timeSpecifier != null) { types.put(LogEntry.FIELD_TIMESTAMP, FieldBaseTypes.DATE); } if (levelSpecifier != null) { types.put(LogEntry.FIELD_SEVERITY_LEVEL, FieldBaseTypes.SEVERITY); } return types; } Log4jTextReader();  Log4jTextReader(final String conversionPattern, final String charset); @Override List<SeverityLevel> getSupportedSeverities(); @Override LinkedHashMap<String, FieldBaseTypes> getFieldTypes(); Locale getLocale(); void setLocale(final Locale locale); String getTimeZone(); void setTimeZone(final String timeZone);  }
@Test public void testParsingConversionPattern() throws FormatException { final Log4jTextReader r = new Log4jTextReader(); r.setFormatPattern("%d{ABSOLUTE} %-5p [%c] %m%n"); r.setCharset("UTF-8"); r.setSpecifiersFieldMapping(Collections.singletonMap("m", "Message")); final String[] fieldNames = r.getFieldTypes().keySet().toArray(new String[0]); Assert.assertEquals(7, fieldNames.length); Assert.assertEquals(LogEntry.FIELD_RAW_CONTENT, fieldNames[0]); Assert.assertEquals("d", fieldNames[1]); Assert.assertEquals("p", fieldNames[2]); Assert.assertEquals("c", fieldNames[3]); Assert.assertEquals("Message", fieldNames[4]); Assert.assertEquals(LogEntry.FIELD_TIMESTAMP, fieldNames[5]); Assert.assertEquals(LogEntry.FIELD_SEVERITY_LEVEL, fieldNames[6]); Assert.assertEquals(FieldBaseTypes.DATE, r.getFieldTypes().get(LogEntry.FIELD_TIMESTAMP)); Assert.assertEquals(FieldBaseTypes.STRING, r.getFieldTypes().get(fieldNames[0])); Assert.assertEquals(FieldBaseTypes.STRING, r.getFieldTypes().get(fieldNames[1])); Assert.assertEquals(FieldBaseTypes.STRING, r.getFieldTypes().get(fieldNames[2])); Assert.assertEquals(FieldBaseTypes.STRING, r.getFieldTypes().get(fieldNames[3])); Assert.assertEquals(FieldBaseTypes.STRING, r.getFieldTypes().get(fieldNames[4])); Assert.assertEquals(FieldBaseTypes.DATE, r.getFieldTypes().get(fieldNames[5])); Assert.assertEquals(FieldBaseTypes.SEVERITY, r.getFieldTypes().get(fieldNames[6])); }