How to format log file if structure of lines is different?



If the log format has the following problems:

  1. Not the same number of columns on all the lines.
  2. if you have words(columns) you want to drop.
  3. if you want to drop non numeric characters from certain columns.(not a mandatory feature)
  4. ignore lines that their size is less then a certain number.




run the attached jar with the right arguments supplied



java -jar fileFixer.jar file=c:\Users\ziv.hilu\Documents\tickets\10391\fromTicket\sjc-sample_orig.txt "wordsToDrop=reason=\"TCP FIN\" , reason=\"TCP RST\" , reason=\"unset\" " columnsToFix=28,30 delimiter=32 lineSize=31



  1. file is the log file you want to parse.
  2. wordsToDrop is words you want to drop from the file separated by comma. remember that if words contain special characters it needs to be escaped with \.
  3. columnsToFix(Optional) is columns you want to drop non numeric characters from its value. 
  4. delimiter(Optional) is the delimiter in the file



The result will be a log file with name fixedFile.log on the same location where the original log were.





Have more questions? Submit a request


Powered by Zendesk