Bring color to your logs

27.11.2013.

Logging has been one of the main “non-intrusive” approaches for application monitoring and troubleshooting in the developer’s toolbox. It is very useful tool because it enables analysis of the application behaviour after the problematic behaviour. Therefore developers typically use specialized logging libraries (such as log4j), that enable easy configuration, filtering and targeting changes. Unfortunately, in the larger programs there can be many inconsistencies in the log levels that are used to write the information into log. We have noticed a tendency to bring all information on at most 3 levels (DEBUG, WARN and ERROR). Even with these three levels, there is rarely enough effort incorporated and messages are usually badly balanced. In this situation, adding INFO and FATAL levels leads to additional confusion.

To make developers better aware of logging levels and their importance during the development phase, it is useful to introduce color coding of different levels in the development tool such as Eclipse. It helps the developer by using visual aid to quickly find important and error messages in the log, which are usually surrounded by a high level of debug output from the nearby statements. Furthermore, it increases developer awareness of importance of using proper log levels for different messages (for example, it is not really appropriate to log complete stack trace on ERROR or FATAL levels).

Grep console

Grep console – is a relatively simple addon that enriches console output with coloring rules based on defined keywords. (It is already set up to monitor [DEBUG], [INFO], …, but can be modified, for example, to exclude square brackets.

URL to check is: http://marian.schedenig.name/projects/grep-console/

Plugin can easily be installed using update site as described here http://marian.schedenig.name/wp-content/static/grepconsole_userguide/

To install Grep Console from the Update Site, select Help/Software Updates/Available Software from your Eclipse menu and check Grep Console and click Install to begin the installation process.

Log viewer

Log viewer can be used to tail a specific file. While displaying information, it can add color to a line according to specified rules. After installation there are no specific rules set up, but in just a few minutes one can add rules for desired loglevels.

URL to check is:  https://github.com/anb0s/logviewer

The installation can be done by setting following URL as update site, and installing from there as described here https://github.com/anb0s/logviewer/wiki/Install