I want to remove specific lines from log files that contain specific words to make sorting through error messages easier. I found the bookmark method, but that only works for one file at a time. I want a Find All in all files that will remove an entire line when it finds a specific string that I set it to find.
Example line from log: 2019-06-14 08:44:49.4053 ERROR 14 My.Services.Remove.Me System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it.
I want to find all that include "My.Services.Remove.Me" and remove the entire line.
Using regular expressions in Notepad++ (some random blog site I found that discusses these in case you are unfamiliar with regex and shows images on how to do it), you need to match the end of the line, and wildcard the entire line as follows:
Find:
.*My\.Services\.Remove\.Me.*\r\n
and leave the Replace box empty
Test case example:
2019-06-14 08:44:49.4053 ERROR 14 My.Services.Remove.Me System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it.
2019-06-14 08:44:49.4054 test
2019-06-14 08:44:49.4058 ERROR 14 My.Services.Remove.Me System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it.
2019-06-14 08:44:49.4081 hello
2019-06-14 08:44:49.4088 ERROR 14 My.Servces.Remove.Me System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it.
2019-06-14 08:44:49.5001 WARN 12 Yes
Note how the 2nd last line has Servces
instead of Services
so it won't match that one. Now we run it with Replace All:
2019-06-14 08:44:49.4054 test
2019-06-14 08:44:49.4081 hello
2019-06-14 08:44:49.4088 ERROR 14 My.Servces.Remove.Me System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it.
2019-06-14 08:44:49.5001 WARN 12 Yes
All of the lines that match have been removed.
User contributions licensed under CC BY-SA 3.0