Looking at your WSO2 logs using rtail / NodeJS

Posted by Rob Blaauboer on 20 Apr, 2017
Find me on:

In some cases you will run a WSO2 product on a machine somewhere in the cloud or on a server somewhere in the organization. Our use case is porting our training environment to a Amazon AWS environment running on a minimal install of CENTOS.

When you start with WSO2 (but also as an experienced developer) access to the logs in an easy way will help you in learning WSO2 since the console is like a thermometer, it will tell you what is going on.

We want to have a simple solution to access the logs real-time. Of course we can use PuTTY/SSH to log in to our server and use the command.

tail -f /opt/wso2esb-5.0.0/repository/logs/wso2carbon.log

Looking at your WSO2 logs using rtail / NodeJS - PuTTY Configuration


This will actually do the trick, but there should be a better solution. One of my colleagues suggested rtail.

What is rtail?

Rtail is an open source command line utility that grabs every line in stdin and broadcasts it over UDP. Let’s look at the two perhaps unknown words: stdin and UDP.

Stdin is the standard input channel of your computer, User Datagram Protocol (UDP) is part of the Internet Protocol suite used by programs running on different computers on a network.

Short and sweet, rtail grabs input and transmits it for you to take a look at.

Centos@ip.png

Installing rtail

NodeJS.png

But how do we install rtail? It is quite easy. Since rtail is based on node.js we need to install that environment first.

Make sure you have root privileges (for instance using sudo su - ) and enter this command:

curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

This installs the NodeSource Node.js 6.x repo on your machine. Mind you, it does not install node.js, just the repo.

Run as root

yum install -y nodejs

to install Node.js 6.x and npm.

Node-harmony app.js_rtail.png

To install rtail, use the node package manager (npm):

npm install -g rtail

This completes the installation of rtail and of course Node.js as a platform.

Getting rtail up and running

What we now need to do is to setup the rtail-server. The parameters are actually quite simple:

Rtail-server –web-host [your-IP] –-web-port 8888

The [your-IP] is the IP address of your machine and the web port is the port that we are using. The latter parameter is the default value so can be omitted.

With the rtail-server up and running we can TAILF (tail a file continuously) the wso2carbon.log to rtail with the ID wso2ESB. The rtail-server can listen to multiple stream so having an id is handy to identify the streams. The ‘&’ makes sure it runs as a background process

tailf /opt/wos2/wso2esb-5.0.0/repository/wso2carbon.log | rtail --id wso2ESB &

Voila!

And there it is, the wso2carbon log neatly displayed in the browser, taking it from a server running for instance on Amazon. A simple yet elegant solution.

With thanks to our colleague Joey for his suggestion of rtail!

Rtail.png

Thanks to Thijs Volders for his contribution to this blog.

If you have any questions about this blogpost contact us via the comments section of this blog. For more View also our WSO2 Tutorialswebinars or white papers for more technical information. Need support? We do deliver WSO2 Product Support, WSO2 Development SupportWSO2 Operational Support and WSO2 Training Programs.  

New Call-to-action

Topics: WSO2

Written by Rob Blaauboer

Rob Blaauboer
Rob is a Senior Business Consultant and Solution Architect with more than twenty years experience. In addition to his work he is an active blogger working on a number of articles on the ‘Internet of Things’ and a WSO2 ‘Getting Started with …’ series (WSO2 tutorial) in which he talks about WSO2 components and their purpose especially aimed at non technical readers. Rob is a WSO2 expert and official WSO2 trainer.

Find me on: