Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tail multiple files shown by separate colors?

Tags:

bash

logging

I follow multiple log files like this:

tail -f /var/log/apache2/tv7r9r3falz0_error.log protected/runtime/application.log

Is there a way to color each file so I don't have to rely on finding the headers:

==> protected/runtime/application.log <==

I know about multitail, but I want to freely scroll.

like image 671
Elliot Chance Avatar asked Sep 29 '22 17:09

Elliot Chance


1 Answers

This will print the output in two different colors depending on which log file it comes from:

tail -f log1 log2 | awk $'/==> log1/{print "\033[0m\033[1;33;40m";} /==> log2/{print "\033[0m\033[1;35;40m";} 1'

Update by Elliot Chance: Thats the start I needed, here was the working version:

tail -f /var/log/apache2/tv7r9r3falz0_error.log protected/runtime/application.log | awk '/==> /{print "\033[0m\033[1;36;40m";} /==> p/{print "\033[0m\033[1;33;40m";} {print $0}'
like image 85
John1024 Avatar answered Oct 19 '22 06:10

John1024