in src/main/java/org/apache/log4j/varia/LogFilePatternReceiver.java [518:585]
protected void process(BufferedReader bufferedReader) throws IOException {
Matcher eventMatcher;
Matcher exceptionMatcher;
String readLine;
//if newlines are provided in the logFormat - (NL) - combine the lines prior to matching
while ((readLine = bufferedReader.readLine()) != null) {
StringBuilder line = new StringBuilder(readLine);
//there is already one line (read above, start i at 1
for (int i = 1; i < lineCount; i++) {
String thisLine = bufferedReader.readLine();
if (thisLine != null) {
line.append(newLine).append(thisLine);
}
}
String input = line.toString();
eventMatcher = regexpPattern.matcher(input);
//skip empty line entries
if (input.trim().equals("")) {
continue;
}
exceptionMatcher = exceptionPattern.matcher(input);
if (eventMatcher.matches()) {
//build an event from the previous match (held in current map)
ChainsawLoggingEvent event = buildEvent();
if (event != null) {
if (passesExpression(event)) {
append(event);
}
}
currentMap.putAll(processEvent(eventMatcher.toMatchResult()));
} else if (exceptionMatcher.matches()) {
//an exception line
additionalLines.add(input);
} else {
//neither...either post an event with the line or append as additional lines
//if this was a logging event with multiple lines, each line will show up as its own event instead of being
//appended as multiple lines on the same event..
//choice is to have each non-matching line show up as its own line, or append them all to a previous event
if (appendNonMatches) {
//hold on to the previous time, so we can do our best to preserve time-based ordering if the event is a non-match
String lastTime = (String) currentMap.get(TIMESTAMP);
//build an event from the previous match (held in current map)
if (currentMap.size() > 0) {
ChainsawLoggingEvent event = buildEvent();
if (event != null) {
if (passesExpression(event)) {
append(event);
}
}
}
if (lastTime != null) {
currentMap.put(TIMESTAMP, lastTime);
}
currentMap.put(MESSAGE, input);
} else {
additionalLines.add(input);
}
}
}
//process last event if one exists
ChainsawLoggingEvent event = buildEvent();
if (event != null) {
if (passesExpression(event)) {
append(event);
}
}
}