satyagraha / logviewer

Provides a capability to tail log files in a web browser, implemented using websockets.
63 stars 25 forks source link

logviewer

Overview

This project provides a capability to tail log files in a web browser. It uses the emerging websockets technology to stream new log lines to the browser for display in a scrollable text area. The log files tailed may be either on a filesystem locally mounted on the web application server, or on a remote server accessible via ssh.

Browser Compatibility

The client-side software is written in Javascript, and browser compatibility as at autumn 2012 is as follows:

A comprehensive table of browser websocket support is here.

Server-side Support

The server-side implementation of websockets does not as yet have a standard Java API. Therefore different web container providers require the use of container-specific classes to service websocket actions.

The implementation provided here comes with:

A separate Play framework project using the common core is available [here]().

There is no reason implementations could not be provided for other containers without too much difficulty.

Getting Started

Tailing Server-local Files

Click the pick log File pulldown to select a file to be tailed.

Tailing Server-remote Files

IDE Users

Note that, at the time of writing, the standard Eclipse Maven plugin m2e has an issue whereby source code cannot be found when debugging with the above Jetty/Tomcat7 run configuratations: this is due to dynamic code loading, see the bug report. As an interim fix, an additional m2e extension plugin may be installed from here which provides the currently missing functionality.

Javadoc

Execution of the command:

at base directory level will result in Javadoc being created under javadoc/site/apidocs.

Principles of Operation

Communication between client- and server-side is very simple, using one JSON-encoded object, declared as a LogMessage in the Java codebase. On loading the web page the user is presented with a list of available log files, and when one is selected then updates are sent to refresh the web page text area. The updating is continuous, unless paused via the provided checkbox.

The following additional Javascript libraries are used:

The server-side component implements the appropriate container servlet and responds to the messages as necessary. We use the Apache CommonsIO Tailer to perform the tracking of the log file.

A simple implementation of the standard Java Executor interface is provided to manage the necessary thread pool.

Log Generator

A utility program named LogGenerator is provided: it writes to a log file on a regular basis to simulate what would happen with a real log file, and is useful during testing. The log file location is configured in logviewer-common/src/main/resources/generator.log4j.properties.

To run the generator, from the main working directory do the following:

which generates 100 lines of output then exits. Omit the line limit number to make the program run indefinitely.

Notes

License

Apache V2.0

Revision History