What is the best way to correct parse log file?

user388794

I want to parse java log. I need to get only Error log with tracer.

For example:

2022-06-21 19:19:56,665 ERROR [scheduler-3] o.s.s.s.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task 
java.lang.NullPointerException: null
    at ...
    at ...
    ...
2022-06-21 19:19:56,666 DEBUG 

I need take all until new log line with data. It is:

2022-06-21 19:19:56,665 ERROR [scheduler-3] o.s.s.s.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task 
java.lang.NullPointerException: null
        at ...
        at ...
        ...

What is the best way to make regular expression for this task with repeating symbols? In my way there are something like that .+\n\t If I not use repeat it seems ugly, like that REG_EXP_2 = r'\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2},\d{3}\sERROR.+\n.+\n\t.+\n\t.+' So I need to find all log strings with model .+\n\t until I will find new data line.

I triet to use model with repeating symbols, but it parses only last finding string.

Thank you.

The fourth bird

To match ERROR amd all the following lines that do not start with a date:

^\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2},\d{3}\sERROR\b.*(?:\n(?!\d{4}-\d{2}-\d{2}\s).*)*

Regex demo

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

What is the best way to parse this configuration file?

What is the best way to Parse a scanned PDF file using PHP or JS?

What is the best log file format?

What is the correct way to parse variables using JavaParser?

What is the best Pythonic way to parse this data?

What is the best way to parse binary protocols with Rust

What is the best way to strictly parse string to enum?

What's the best way in PowerShell to parse these strings?

Flutter - What is the best way to parse Json?

What is the best way to parse a line using Java?

the best way to parse and validate YAML configuration file

bash - The Best Elegant way to disable log file

Best way to roll log file in GO

What is the best way to read a file in Java?

What is the best way to save a complex dictionary to file?

What is the best way to upload a (requested) file with jersey?

What is the best way to download a big file in NodeJS?

What is the best way to transfer a file using Java?

what is the best way to edit csv file

What could be the best way to get file path

What is the best way to do a substring in a batch file?

What is the best way to upload a file to server?

What is the best way to save credentials file with Python?

What is the best way to write a struct to file?

what is the best way to upload file with javaee maven

In terms of usability, what is the best way to export a file?

what is the best way to get the pst file sizes

What is the best way to create a JS embed file?

What is the best / correct way to export Docker image with reduced size