9 Apr 2013

How to change colors in Karaf shell console?


Karaf uses colored output, this is great!!
E.g. running log:tail or log:display prints the karaf log in different colors depending on the log level of the log message.

However sometimes the colors used by default don't work nicely on your terminals background.
You could change the background  of the terminal but would it not be nicer to simple reconfigure the color codes used by Karaf?

Of course this is possible.
Simply add something like the following to $KARAF_HOME/etc/org.apache.karaf.log.cfg


#
# ANSI Colors
#
fatalColor = 31;1
errorColor = 31;1
warnColor = 35
infoColor = 36
debugColor = 39
traceColor = 39


and restart your Karaf/ServiceMix/Fuse ESB Enterprise/JBoss Fuse container.
How do these values map to actual colors? See http://en.wikipedia.org/wiki/ANSI_escape_code#graphics, in particular the section on colors.

Appending a ";1" to the color value renders the text in bold as well. Other formatting options such as italic or blinking don't seem to be supported.






3 comments:

Anonymous said...

To change the text background, use codes 40 to 47 as well, for example

fatalColor = 47;31

Chris Caspanello said...

This didn't seem to work for me.

karaf@root()> config:edit org.apache.karaf.shell.log
karaf@root()> property-list
debugColor = 37
errorColor = 37
fatalColor = 37
felix.fileinstall.filename = file:/C:/___/assembly/etc/org.apache.karaf.shell.log.cfg
infoColor = 37
service.pid = org.apache.karaf.shell.log
traceColor = 37
warnColor = 37

Any ideas?

Eric Schiesser said...

Hi y'all. This is the first hit on google when searching for "Karaf colors." I am trying to figure out where to change the colors for the code completion colors when logged in to a Karaf console via ssh. I can't seem to figure out where those are defined. Any insights?

I tried to grep through the karaf .cfg files for color codes to no avail. Any help would be appreciated!