Advertisement
5t0ff31

Logfile Search

Dec 2nd, 2017
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import re
  5.  
  6. matched = []
  7.  
  8. log = open("Logfile.log")
  9. log_duplicates = open("Logile_duplicate.log", "w")
  10.  
  11. for line in log:                
  12.     match = re.search(r'ERROR.+', line)
  13.     if match:
  14.        match_string = match.group()
  15.        if not match_string in matched:
  16.          print(match_string)
  17.          matched.append(match_string)
  18.          log_duplicates.write(match_string + "\n")
  19.        
  20. log.close()
  21. log_duplicates.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement