Friday 23 July 2010

install grc

add match in /etc/grc.conf

add corresponding conf file in /usr/share/grc

for example log4j


#Colours are one of:
# none, default, bold, underline, blink, reverse, concealed,
# black, green, yellow, blue, magenta, cyan, white,
# on_black, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white
# beep
#
#count is one of words: once, more, stop, previous, block or unblock
#
# * once means that if the regexp is matched, its first occurrence is coloured
# and the program will continue with other regexp's.
#
# * more means that if there are multiple matches of the regexp in one line,
# all of them will be coloured.
#
# * stop means that the regexp will be coloured and program will move to the
# next line (i.e. ignoring other regexp's)
#
# * previous means the count will be the same as for the previous line
#
# * block marks a start of a multiline block of text, coloured with
# the same colour
#
# * unblock, obviously, marks the end of such a block

regexp=\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\W\d{3}
colours="\033[1;38;5;16m"
count=more
=====
regexp=INFO\s+\[.+\]
colours=blue
count=once
=====
regexp=\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\W\d{3}\s+INFO
colours=on_blue
count=once
=====
regexp=DEBUG\s+\[.+\]
colours=green
count=once
=====
regexp=\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\W\d{3}\s+DEBUG
colours=on_green
count=once
=====
regexp=WARN\s+\[.+\]
colours=yellow
count=once
=====
regexp=\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\W\d{3}\s+WARN
colours=on_yellow
count=once
=====
regexp=ERROR\s+\[.+\]
colours=red
count=once
=====
regexp=\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\W\d{3}\s+ERROR
colours=on_red
count=once


Then use grc:

grc tail -300f x.log

this will trigger the log.conf file and colourize the tail output

No comments: