Skip to content

Instantly share code, notes, and snippets.

@masonwan
Last active June 12, 2023 18:55
Show Gist options
  • Save masonwan/7956055 to your computer and use it in GitHub Desktop.
Save masonwan/7956055 to your computer and use it in GitHub Desktop.
Print out Tomcat log file "catalina.out" with color
tail -200 catalina.out | ack-grep --flush --passthru --color --color-match=red "^.*ERROR.*" | ack-grep --flush --passthru --color --color-match=green "^.*DEBUG.*"
@ElMesa
Copy link

ElMesa commented Nov 22, 2014

If u are interested i forked the gist and included the colors info with attribution included:
https://gist.github.com/ElMesa/374c556283972e96deef

@tfga
Copy link

tfga commented Sep 3, 2021

Here are my contributions, based on @ElMesa's fork:
https://gist.github.com/tfga/26c22026d9aeb9c0df3db2b39ccfbf88

  • Refactored the code to use functions, so now the main code looks like this:

    colorize red    "ERROR"                 | \
    colorize red    "SEVERE"                | \
    colorize green  "DEBUG"                 | \
    colorize yellow "Deploying|finished"    | \
    colorize blue   "INFO"
  • You can colorize the whole line or just "the word" / regex match (e.g. ERROR, SEVERE).

  • Made it a pipe:

    catalina.sh run 2>&1 | colorizeTomcat
    tail -200 catalina.out | colorizeTomcat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment