Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tmoreira2020 opened this issue Nov 6, 2024 · 9 comments
Open
Labels
question Further information is requested

Comments

@tmoreira2020
Copy link

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!

@baubakg
Copy link
Member

baubakg commented Nov 6, 2024

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 baubakg added the question Further information is requested label Nov 6, 2024
@tmoreira2020
Copy link
Author

tmoreira2020 commented Nov 6, 2024

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?

@baubakg
Copy link
Member

baubakg commented Nov 6, 2024

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?

@tmoreira2020
Copy link
Author

tmoreira2020 commented Nov 6, 2024

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.

@baubakg
Copy link
Member

baubakg commented Nov 8, 2024

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.

@tmoreira2020
Copy link
Author

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?

@baubakg
Copy link
Member

baubakg commented Nov 8, 2024

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

@tmoreira2020
Copy link
Author

Yes, correct!

@baubakg
Copy link
Member

baubakg commented Nov 12, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants