Practical Web Programming

Tuesday, April 15, 2014

Watching Log Files Using tail and less

Watch the error log and filter the output to the screen (using grep).

tail -f /var/log/apache/error.log | grep -v Exception | grep -v 'PHP Notice'

Output the error log to the screen, filter it before doing so (using grep).

less +F /var/log/apache/error.log | grep -v Exception | grep -v 'PHP Notice'

Note:

-v parameter in grep is reverse look up. It mean, all text except 'Exception' and 'PHP Notice'


Forward and Backward Search in less

/ – search for a pattern which will take you to the next occurrence. 
? – search for a pattern which will take you to the previous occurrence. 
n – for next match in backward direction 
N – for previous match in forward direction
Shift F - similar to tail -f

0 comments:

Recent Post