Benjamin
Benjamin

Reputation: 10403

How can I see the colored log using tail or less?

enter image description here

Reading a Rails log with vim, we can see a colored log. But when we use tail -f or less to watch the log, it isn't colorized anymore. Is there any way to see the colored log with tail or less or whatever?

Upvotes: 12

Views: 7232

Answers (3)

chech
chech

Reputation: 1105

tail -f log/development.log | ccze -A

You may need to install ccze

sudo apt-get install ccze

it works better, not ideal but works

Upvotes: 8

Frederick Cheung
Frederick Cheung

Reputation: 84172

pass -R to less for it to let colour escape sequences pass through, i.e.

less -R log/development.log

This should result in them being displayed in colour, assuming you are using the proper terminal type

Upvotes: 22

Oscar Del Ben
Oscar Del Ben

Reputation: 4515

You can't do that out of the box, since tail and less know nothing about Rails, and logs are saved a simple text files. You could use regular expressions to colorize output but I doubt it's worth the trouble.

EDIT: see alfonso's comment for some alternatives.

Upvotes: 1

Related Questions