Multi line Log Parser in Python
By Fahad Ahammed
- One minute read - 166 wordsSo, I have a log file that is not single line log. It is kind of java stack trace. What I needed to do is read those log files and create some actions depending on them. I could use already built tools. But I thought why not just do this as simply as printing strings.
This is an example of the log format I wanted to play with. It seems too simple to pile up the Filebeats or elastic stack.
So, I have that log format. First I want to read the file.
This log_file_obj is now a list of lines of the log file. It can be a huge object in the memory. But as I have fixed and limited size log files, I can risk opening them like that.
If logs were single lined, I could use this list to do the actions. But What I had to do is this.
Thus the output should be –
This is just a simple code snippet.