log-parser icon indicating copy to clipboard operation
log-parser copied to clipboard

Is it possible to parse a log that contains a java stacktrace?

Open tmoreira2020 opened this issue 1 year ago • 9 comments

I looked over the source code and couldn't figure out if it is possible to read/parse a java stacktrace. Is it possible? Or customizable?

Thanks

p.s. great work by the way!

tmoreira2020 avatar Nov 06 '24 02:11 tmoreira2020

Thanks for your nice words and a great question.

To be completely frank I have never tried it, and it was not really ment for it. Any suggestions for a specific use case?

baubakg avatar Nov 06 '24 09:11 baubakg

I would like to analize tomcat's server error with and without exceptions. In the end of the day I would like to have a summary of exceptions that happened in a timeframe. Do you think that it is possible to implement?

tmoreira2020 avatar Nov 06 '24 15:11 tmoreira2020

Well it is worth looking into.

Finding data in a timeframe is included in the latest version. The tricky part may be how exceptions are logged in tomcat. I'll give it a try.

The log-parser will not be be able to to treat both errors and stack traces in the same time. I'll prepare an example, and we can agree on the outcome.

Would that work for you?

baubakg avatar Nov 06 '24 15:11 baubakg

The log-parser will not be be able to to treat both errors and stack traces in the same time

Sounds good! I'm okay to run twice the parser with different ParseDefinition if it is necessary. Let me know how I can help in this process. I already have a PoC running on my side analysing my logs.

tmoreira2020 avatar Nov 06 '24 18:11 tmoreira2020

Hi @tmoreira2020 as a starting point I have created a small example: branch: tomcat Test: com.adobe.campaign.tests.logparser.core.LogDataTest#testHelloTomcat Test file: src/test/resources/logTests.tomcat/catalina.example.log

The outout I get is:

20-Sep-2024 06:01:02.946#|;20-Sep-2024 06:01:02.946;|;main;org.apache.tomcat.util.net.Acceptor.stopMillis The acceptor thread [http-nio-1234-Acceptor] did not stop cleanly;1
29-Oct-2024 09:15:01.048#|;29-Oct-2024 09:15:01.048;|;http-nio-1234-exec-3;org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [neolanejsp] in context with path [/nl/jsp] threw exception [An exception occurred processing [uploadFile.jsp] at line [82];1
29-Oct-2024 09:15:01.050#|;29-Oct-2024 09:15:01.050;|;http-nio-1234-exec-11;org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [neolanejsp] in context with path [/nl/jsp] threw exception [An exception occurred processing [uploadFile.jsp] at line [82];1

Tell me what you would to have an an output.

baubakg avatar Nov 08 '24 12:11 baubakg

hey @baubakg , thanks for the quick follow up and sample.

The sample that you provided is halfway of what I'm looking for. The second half would be a way to retrieve the stacktrace of the exception via LogData<GenericEntry> object. Makes sense?

tmoreira2020 avatar Nov 08 '24 17:11 tmoreira2020

Ok good. If I understand you correctly, ideally you want the stack trace attached to the relevant logEntry? Is that correct?

baubakg avatar Nov 08 '24 17:11 baubakg

Yes, correct!

tmoreira2020 avatar Nov 08 '24 20:11 tmoreira2020

Ok I think we have a design limitation, as the log-parser in its current form, works with only one line at a time. Even multiple parsings will have the issue of deducing the relationship between the findings.

I think we should consider a future feature where we accept that a log entry can be multi-lined.

It is a bit tricky though, as there are two options:

  • Instead of using the EOLN as a log entry ending, we store everything between two findings
  • We define a multiline repeatable pattern. Instead of one parse definition, we pass a series of parse definitions. This will represent a multi-line pattern.
    • We will need to also to have a repetitive storage, that for a stacktrace pattern we fetch all the stacktraces.

However for now we cannot solve this I am afraid.

baubakg avatar Nov 12 '24 09:11 baubakg