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?
Asked
Active
Viewed 6,411 times
12

Benjamin
- 10,085
- 19
- 80
- 130
-
1http://unix.stackexchange.com/questions/8414/how-to-have-tail-f-show-colored-output – alf Jun 24 '12 at 16:27
-
`grc` is exactry what I wanted. thank you so much. – Benjamin Jun 24 '12 at 16:30
3 Answers
21
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

Frederick Cheung
- 83,189
- 8
- 152
- 174
-
1
-
1The colours come from unprintable characters that tell your terminal to switch colours. If your terminal isn't configured to display colours this will do nothing. How you set this up is platform dependant - on OS x's standard terminal it's the ANSI colors setting. – Frederick Cheung Jun 24 '12 at 17:11
7
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

chech
- 1,085
- 14
- 21
1
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.

Oscar Del Ben
- 4,485
- 1
- 27
- 41
-
You are right. It was a simple text file. Though, how can it be seen colorized in vim? The file extension was just `.log` Nothing special. – Benjamin Jun 24 '12 at 16:41
-