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?
The tail command, as the name implies, print the last N number of data of the given input. By default it prints the last 10 lines of the specified files. If more than one file name is provided then data from each file is precedes by its file name.
In less , you can press Ctrl-C to end forward mode and scroll through the file, then press F to go back to forward mode again. Note that less +F is advocated by many as a better alternative to tail -f .
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With