开发者

apache tomcat output with colors in Linux terminal

I usually use tomcat plugin in eclipse and run it from eclipse.开发者_开发百科 Now I want to use it from terminal. but the problem is I dont get the output in colors. Atleast the errors should be displayed in red .

Any idea how to achieve this ?

EDIT: If no such tool exists, can anyone guide me to create one. I am interested to create one such tool.


yes there is a way actually, first you need to make apache tomcat log using log4j instead of the default logger. Then you can actually customize the output for log4j. You are going to have to read a bit on logging for tomcat, and about log4j, you can have console output configured and then you can have what ever colors you need in them since they are customizable.

Some links that will help you .

http://tomcat.apache.org/tomcat-6.0-doc/logging.html

http://marc.info/?l=log4j-user&m=120574713010072


Try this class written by Dan Dyer.


You can try ccze , but still not perfect work with less or tail, works well with static log


Turn on grep's line buffering mode.

  1. Using tail

    tail -f fileName | grep --line-buffered my_pattern
    
  2. Using less

    less +F fileName | grep --line-buffered my_pattern
    
  3. Using watch & tail to highlight new lines

    watch -d tail fileName 
    
    • For linux based systems.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜