Junior — Middle
How can command line be used to find specific exceptions in log files?
sobes.tech AI
Answer from AI
To find specific exceptions in log files via command line, you can use the grep utility. For example, to find all lines containing the word "Exception":
grep "Exception" log_file_name.log
If you need to search case-insensitively or use regular expressions, you can add flags:
-i— ignore case-E— use extended regular expressions
Example: find all exceptions starting with "NullPointerException":
grep "NullPointerException" log_file_name.log
You can also use tail -f to view logs in real-time with filtering:
tail -f log_file_name.log | grep "Exception"