ppkarwasz commented on issue #2162: URL: https://github.com/apache/logging-log4j2/issues/2162#issuecomment-1876927239
You are calling [`BufferedReader#readLine()`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/BufferedReader.html#readLine()) **twice** per loop iteration. Try: ```java JsonLogEventParser parser = new JsonLogEventParser(); try (BufferedReader br = new BufferedReader(new FileReader(logFilePath))) { String line; while ((line = br.readLine()) != null) { // Get LOG Event from line try { LogEvent logEvent = parser.parseFrom(line); ..... } catch(Exception x) { System.out.print("Error parsing log"); throw x; } } } catch(Exception e) { System.out.println(e.getStackTrace().toString()); throw new RuntimeException(e); } ``` You are also assuming that each log line has one JSON object, which might be wrong. BTW: we are considering removing the whole `o.a.l.l.core.parser` package from `log4j-core` (cf. [this thread on `dev@logging`](https://lists.apache.org/thread/12w04yp1z779yn5wbxf84mnx4rsww5ko)). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
