How to colorize tailf output.

How to colorize tailf output.

   KB 23136        Last updated on 03/7/2017  




0.00
(0 votes)


Purpose


The article shows how to add colors to your tail -f output, making the output more readable.


Resolution


The following command add colors to three logging key words: calendar, mailop, misc.

tailf /opt/zimbra/log/mailbox.log | awk '/calendar/ {print "\033[33m" $0 "\033[39m"} /mailop/ {print "\033[1;34m" $0 "\033[39m"} /misc/ {print "\033[1;35m" $0 "\033[39m"}'


The colors you can choose from are:

Black 0;30 Dark Gray 1;30
Blue 0;34 Light Blue 1;34
Green 0;32 Light Green 1;32
Cyan 0;36 Light Cyan 1;36
Red 0;31 Light Red 1;31
Purple 0;35 Light Purple 1;35
Brown 0;33 Yellow 1;33
Light Gray 0;37 White 1;37


The logging key words can be the following:

  • account - Account operations
  • acl - ACL operations
  • activity - Document operations
  • autoprov - Auto provision operations
  • backup - Backup and restore
  • cache - In-memory cache operations
  • calendar - Calendar operations
  • datasource - Data Source operations
  • dav - DAV operations
  • dbconn - Database connection tracing
  • doc - Docs operations
  • ews - EWS operations
  • extensions - Server extension loading
  • filter - Mail filtering
  • gal - GAL operations
  • im - Instant messaging operations
  • imap - IMAP server
  • imap-client - IMAP client
  • index - Indexing operations
  • io - Filesystem operations
  • ldap - LDAP operations
  • lmtp - LMTP server (incoming mail)
  • mailbox - General mailbox operations
  • mailop - Changes to mailbox state
  • milter - MILTER protocol operations
  • misc - Miscellaneous
  • nginxlookup - Nginx lookup operations
  • pop - POP server
  • pop-client - POP client
  • purge - Mailbox purge operations
  • redolog - Redo log operations
  • search - Search operations
  • security - Security events
  • session - User session tracking
  • smtp - SMTP client (outgoing mail)
  • soap - SOAP protocol
  • sqltrace - SQL tracing
  • store - Mail store disk operations
  • sync - Sync client operations
  • system - Startup/shutdown and other system messages
  • zimlet - Zimlet operations


Additional Information


You can also combine tail -f with grep as follows:

tail -f /opt/zimbra/log/mailbox.log | grep <key_word>


And also add colors to grep, as you edit .bashrc and add:

export GREP_OPTIONS="--color=always"
export GREP_COLORS="ms=01;33:mc=01;31:sl=:cx=:fn=1:35:ln=32:bn=32:se=36"

The colors to choose from are the same as listed above.


Verified Against: Zimbra Collaboration 8.6, 8.5, 8.0 Date Created: 03/07/2017
Article ID: https://wiki.zimbra.com/index.php?title=How_to_colorize_tailf_output. Date Modified: 03/7/2017



Try Zimbra

Try Zimbra Collaboration with a 60-day free trial.
Get it now »

Want to get involved?

You can contribute in the Community, Wiki, Code, or development of Zimlets.
Find out more. »

Looking for a Video?

Visit our YouTube channel to get the latest webinars, technology news, product overviews, and so much more.
Go to the YouTube channel »


Wiki/KB reviewed by SME1 SME2 Copy Editor Last edit by Teodor Vizirov
Jump to: navigation, search