@Test public void test_V70標準() { RequestLogParser parser = new RequestLogParser( new ParserParameter(), LogLayoutDefinitions.getStandardRequestLogLayout(Version.V70)); parser.setLogFile(new File("C:/test.log")); String logText = StringUtils.join(new String[] { "[2010-11-30 15:07:31.700]", "[hmux-10.1.83.82:6802-9$26690565]", "1209", "INFO ", "REQUEST_LOG.jp.co.intra_mart.system.servlet.filter.RequestLogFilter", "5hx97pjy0tw3c", "-", "abcMjnWQrAjtv75-mgAYs", "10.48.9.119", "http: "http: "78", "2010-11-30 15:07:31,622", "5hx97pjy0rq12c2" }, "\t"); RequestLog log = parser.parse(logText); assertEquals("2010-11-30 15:07:31.700", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(log.date)); assertEquals("hmux-10.1.83.82:6802-9$26690565", log.thread); assertEquals(1209, log.logReportSequence); assertEquals(Level.INFO, log.level); assertEquals("REQUEST_LOG.jp.co.intra_mart.system.servlet.filter.RequestLogFilter", log.logger); assertEquals("5hx97pjy0tw3c", log.logId); assertEquals("abcMjnWQrAjtv75-mgAYs", log.clientSessionId); assertEquals("10.48.9.119", log.requestRemoteHost); assertEquals("http: assertEquals("http: assertEquals(78L, log.requestPageTime); assertEquals("2010-11-30 15:07:31,622", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS").format(log.requestAcceptTime)); assertEquals("5hx97pjy0rq12c2", 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);  }