For real-time log monitoring with colors, consider these powerful alternatives to plain tail:
# 1. Using multitail (best for multiple logs) sudo pkg install multitail multitail -c /var/log/httpd-error.log# 2. Using ccze (colorizes any log stream) tail -f /var/log/php_errors.log | ccze -AFor systems where you can't install additional packages:
# Colorize with grep highlighting tail -f /var/log/httpd-access.log | grep --color -E 'GET|POST|404|500'# Using sed for basic coloring tail -f error.log | sed -e 's/error/\x1b[31m&\x1b[0m/g' -e 's/warning/\x1b[33m&\x1b[0m/g'For serious production environments:
# Watch multiple logs with different color schemes multitail -cS apache /var/log/httpd-access.log -cS php /var/log/php_errors.log# Persistent logging with lnav lnav /var/log/httpd/*.logFor ccze users, create ~/.cczerc:
[httpd] color info = blue color warning = yellow,bold color error = red,underlineFor multitail, add to ~/.multitailrc:
# Apache scheme colorscheme:apache cs_re:green:\d+\.\d+\.\d+\.\d+ cs_re:yellow:\s4\d\d\s cs_re:red:\s5\d\d\s
When monitoring Apache and PHP error logs in FreeBSD environments, colorized output significantly improves readability and quick pattern recognition. The standard
tail -fcommand lacks this capability, but we can enhance it with these approaches:Install the powerful log colorizer:
pkg install grcCreate a custom configuration file at
~/.grc/apache_logs:regexp=====.*===== colour=blue ====== regexp=\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3} colour=magenta ====== regexp=\$$.*\$$ colour=cyan ====== regexp=PHP (Warning|Error|Notice|Fatal error) colour=red ======Then monitor logs with:
grc tail -f /var/log/httpd-error.logAnother excellent alternative using the log colorizer ccze:
pkg install ccze tail -f /var/log/php_errors.log | ccze -AFor professional environments, consider these powerful tools:
Option 1: MultiTail
Monitor multiple logs simultaneously with colors:
pkg install multitail multitail -cS apache /var/log/httpd-access.log -cS php_errors /var/log/php_errors.logOption 2: lnav
The log file navigator provides syntax highlighting and SQL query capabilities:
pkg install lnav lnav /var/log/httpd-*.logAdd this to your
~/.bashrcor~/.zshrc:colorlog() { case $1 in apache) grc tail -f /var/log/httpd/${2:-error}.log ;; php) tail -f /var/log/php_errors.log | ccze -A ;; *) echo "Usage: colorlog [apache|php] [logtype]" ;; esac }Now simply run:
colorlog apache access colorlog phpWhen monitoring high-traffic servers:
- Use
grc --bufferedto reduce flickering - Consider
ccze -m ansifor minimal overhead - For critical servers, implement log rotation monitoring