@Test public void test_V72標準() { RequestLogParser parser = new RequestLogParser( new ParserParameter(), LogLayoutDefinitions.getStandardRequestLogLayout(Version.V72)); parser.setLogFile(new File("C:/test.log")); String logText = StringUtils.join(new String[] { "[2011-11-13 15:46:58.258]", "[http-APP:localhost:8088-8088-13$412302005]", "18", "INFO ", "REQUEST_LOG.jp.co.intra_mart.system.servlet.filter.RequestLogFilter", "5i0slu6q9cib2", "-", "abceQ4K8o3xXrgffBRBot", "0:0:0:0:0:0:0:1", "POST", "http: "hoge=fuga&im_mark=r-7xij29*vhp35p", "http: "281", "2011-11-13 15:46:57,977", "5i0slu6q94p952g" }, "\t"); RequestLog log = parser.parse(logText); assertEquals("2011-11-13 15:46:58.258", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(log.date)); assertEquals("http-APP:localhost:8088-8088-13$412302005", log.thread); assertEquals(18, log.logReportSequence); assertEquals(Level.INFO, log.level); assertEquals("REQUEST_LOG.jp.co.intra_mart.system.servlet.filter.RequestLogFilter", log.logger); assertEquals("5i0slu6q9cib2", log.logId); assertEquals("abceQ4K8o3xXrgffBRBot", log.clientSessionId); assertEquals("0:0:0:0:0:0:0:1", log.requestRemoteHost); assertEquals("POST", log.requestMethod); assertEquals("http: assertEquals("r-7xij29*vhp35p", log.getQueryValue("im_mark")); assertEquals("http: assertEquals(281L, log.requestPageTime); assertEquals("2011-11-13 15:46:57,977", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS").format(log.requestAcceptTime)); assertEquals("5i0slu6q94p952g", log.requestId); }
public RequestLog parse(String line) { Map<LogLayoutItemType, Object> lineMap = parseLine(line); if (lineMap == null) { return null; } RequestLog log = new RequestLog(); populate(lineMap, log); if (!isInRange(log) || log.isIN() || !isTargetTenant(log)) { return null; } log.requestRemoteHost = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_HOST); log.requestRemoteAddress = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_ADDRESS); log.requestMethod = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_METHOD); log.requestUrl = getUrl((String) lineMap.get(LogLayoutItemType.MDC_REQUEST_URL)); log.requestQueryString = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_QUERY_STRING); log.requestUrlReferer = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_URL_REFERER); log.requestAcceptTime = (Date) lineMap.get(LogLayoutItemType.MDC_REQUEST_ACCEPT_TIME); Long requestPageTime = (Long) lineMap.get(LogLayoutItemType.MDC_REQUEST_PAGE_TIME); if (requestPageTime != null) { log.requestPageTime = requestPageTime; } return log; }
RequestLogParser extends LineLogParser implements LogParser<RequestLog> { public RequestLog parse(String line) { Map<LogLayoutItemType, Object> lineMap = parseLine(line); if (lineMap == null) { return null; } RequestLog log = new RequestLog(); populate(lineMap, log); if (!isInRange(log) || log.isIN() || !isTargetTenant(log)) { return null; } log.requestRemoteHost = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_HOST); log.requestRemoteAddress = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_ADDRESS); log.requestMethod = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_METHOD); log.requestUrl = getUrl((String) lineMap.get(LogLayoutItemType.MDC_REQUEST_URL)); log.requestQueryString = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_QUERY_STRING); log.requestUrlReferer = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_URL_REFERER); log.requestAcceptTime = (Date) lineMap.get(LogLayoutItemType.MDC_REQUEST_ACCEPT_TIME); Long requestPageTime = (Long) lineMap.get(LogLayoutItemType.MDC_REQUEST_PAGE_TIME); if (requestPageTime != null) { log.requestPageTime = requestPageTime; } return log; } }
RequestLogParser extends LineLogParser implements LogParser<RequestLog> { public RequestLog parse(String line) { Map<LogLayoutItemType, Object> lineMap = parseLine(line); if (lineMap == null) { return null; } RequestLog log = new RequestLog(); populate(lineMap, log); if (!isInRange(log) || log.isIN() || !isTargetTenant(log)) { return null; } log.requestRemoteHost = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_HOST); log.requestRemoteAddress = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_ADDRESS); log.requestMethod = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_METHOD); log.requestUrl = getUrl((String) lineMap.get(LogLayoutItemType.MDC_REQUEST_URL)); log.requestQueryString = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_QUERY_STRING); log.requestUrlReferer = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_URL_REFERER); log.requestAcceptTime = (Date) lineMap.get(LogLayoutItemType.MDC_REQUEST_ACCEPT_TIME); Long requestPageTime = (Long) lineMap.get(LogLayoutItemType.MDC_REQUEST_PAGE_TIME); if (requestPageTime != null) { log.requestPageTime = requestPageTime; } return log; } RequestLogParser(ParserParameter parameter, String layout); }
RequestLogParser extends LineLogParser implements LogParser<RequestLog> { public RequestLog parse(String line) { Map<LogLayoutItemType, Object> lineMap = parseLine(line); if (lineMap == null) { return null; } RequestLog log = new RequestLog(); populate(lineMap, log); if (!isInRange(log) || log.isIN() || !isTargetTenant(log)) { return null; } log.requestRemoteHost = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_HOST); log.requestRemoteAddress = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_ADDRESS); log.requestMethod = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_METHOD); log.requestUrl = getUrl((String) lineMap.get(LogLayoutItemType.MDC_REQUEST_URL)); log.requestQueryString = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_QUERY_STRING); log.requestUrlReferer = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_URL_REFERER); log.requestAcceptTime = (Date) lineMap.get(LogLayoutItemType.MDC_REQUEST_ACCEPT_TIME); Long requestPageTime = (Long) lineMap.get(LogLayoutItemType.MDC_REQUEST_PAGE_TIME); if (requestPageTime != null) { log.requestPageTime = requestPageTime; } return log; } RequestLogParser(ParserParameter parameter, String layout); RequestLog parse(String line); }
RequestLogParser extends LineLogParser implements LogParser<RequestLog> { public RequestLog parse(String line) { Map<LogLayoutItemType, Object> lineMap = parseLine(line); if (lineMap == null) { return null; } RequestLog log = new RequestLog(); populate(lineMap, log); if (!isInRange(log) || log.isIN() || !isTargetTenant(log)) { return null; } log.requestRemoteHost = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_HOST); log.requestRemoteAddress = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_ADDRESS); log.requestMethod = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_METHOD); log.requestUrl = getUrl((String) lineMap.get(LogLayoutItemType.MDC_REQUEST_URL)); log.requestQueryString = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_QUERY_STRING); log.requestUrlReferer = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_URL_REFERER); log.requestAcceptTime = (Date) lineMap.get(LogLayoutItemType.MDC_REQUEST_ACCEPT_TIME); Long requestPageTime = (Long) lineMap.get(LogLayoutItemType.MDC_REQUEST_PAGE_TIME); if (requestPageTime != null) { log.requestPageTime = requestPageTime; } return log; } RequestLogParser(ParserParameter parameter, String layout); RequestLog parse(String line);  }