Structuring a log file based on key words

48 Views Asked by At

I'd like to ask for help. I need to know how can i structure a big log file from a device. This is the problem. I am currently working for a company and i have some machines (like ATM/Coffe machine/Drinks/Ciggaretes ...) which devices generate big log files and i want to cut the text in order to find some particular errors during process. I know the option with find but the point is to seperate specific event which has a beginning and ending and something in between. Bthw log files are stored in Notepad, but if there's a solution in Word and Excel it's accepted as well.

Thank you!

2

There are 2 best solutions below

0
Lee Mac On

It would ultimately depend on the structure of the log file in question.

For example, you may be able to import the log file into a DBMS such as MS Access or SQL Server and then run queries to return events which occur within a given time, return a specific error code/description, or match some other criteria of your choice.

0
Sam On

If you're just parsing a text file to find specific words/phrases then you should be able to use grep (on Linux), Select-String (powershell) or FINDSTR (using Windows cmd).

All of these work by checking lines of text for a pattern match, in this case the error message that you're looking for.

So you'd want something along the lines of:

grep <your error message> <the files to search>

And then maybe redirect that to a file so that it's easier for you to read through afterwards.