Colorize log output with ack Posted on October 10, 2009 by garret Adding color to log files makes them a lot easier to understand, especially when tailing them. That’s why tools like MultiTail were created, and some logging tools can output in color. Last night I realized color could be added to any log file using ack, an awesome grep replacement that I recently found. For example, to make 404s red in a standard Apache access log: $ tail -f /var/log/apache2/access.log \ | ack —passthru —color-match=red “^.* 404 .*$” The —passthru option makes it so no lines are discarded. You can use multiple colors by piping the output through ack multiple times. The —flush option is needed to prevent pipe buffering issues and the —color option is needed to pass colors through. Here’s an example: $ tail -f /var/log/apache2/access.log \ | ack —flush —passthru —color —color-match=green “^.* 200 .*” \ | ack —flush —passthru —color —color-match=yellow “^.* 302 .*” \ | ack —flush —passthru —color —color-match=red “^.* 404 .*” (via Colorize log output with ack | powdahound.com)

Colorize log output with ack Posted on October 10, 2009 by garret Adding color to log files makes them a lot easier to understand, especially when tailing them. That’s why tools like MultiTail were created, and some logging tools can output in color. Last night I realized color could be added to any log file using ack, an awesome grep replacement that I recently found. For example, to make 404s red in a standard Apache access log: $ tail -f /var/log/apache2/access.log \ | ack —passthru —color-match=red “^.* 404 .*$” The —passthru option makes it so no lines are discarded. You can use multiple colors by piping the output through ack multiple times. The —flush option is needed to prevent pipe buffering issues and the —color option is needed to pass colors through. Here’s an example: $ tail -f /var/log/apache2/access.log \ | ack —flush —passthru —color —color-match=green “^.* 200 .*” \ | ack —flush —passthru —color —color-match=yellow “^.* 302 .*” \ | ack —flush —passthru —color —color-match=red “^.* 404 .*” (via Colorize log output with ack | powdahound.com)