GithubHelp home page GithubHelp logo

aruld / logviewer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from satyagraha/logviewer

0.0 2.0 0.0 246 KB

Provides a capability to tail log files in a web browser, implemented using websockets.

Java 52.80% HTML 5.40% JavaScript 41.80%

logviewer's Introduction

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:

  • Firefox - excellent, tested
  • Chrome - excellent, tested
  • MS IE - limited
  • Safari - believed to work, but not tested

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 common core log viewer service which is independent of the container
  • a common J2EE servlet 2.5 abstraction module
  • an Apache Tomcat 7.0.30 servlet adapter using the two common modules
  • a codehaus Jetty 7.6.7 servlet adapter using the two common modules
  • a Glassfish Grizzly implementation using the common core service only

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

  • Ensure you have Git and Maven installed on your system
  • Copy the URL in the Git Read-Only entry field at the top of this web page to the clipboard
  • Change working directory to an appropriate location for the checkout, then execute: git clone url
  • Change working directory to the newly created logviewer subdirectory
  • Edit the file logviewer-common/src/main/resources/LogConfigDefault.properties to adjust log directory if required
  • Ensure you have environment variable JAVA_HOME set to reference a Java 6 JDK (not JRE), e.g. on Windows:
  • set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_35
  • Build the complete system thus:
  • mvn.bat clean install
  • For Jetty, execute:
    • cd logviewer-webapp
    • mvn.bat -P jetty clean jetty:run
  • For Tomcat, execute:
  • cd logviewer-webapp
  • mvn.bat -P tomcat clean tomcat7:run
  • For Grizzly, execute:
  • cd logviewer-grizzly
  • mvn.bat exec:java
  • Open web URL http://localhost:8080/logviewer/display.html
  • The resulting web page should be visible in the usual way

Tailing Server-local Files

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

Tailing Server-remote Files

  • Enter a URI in the entry field, typically in the form: ssh://userid@hostname/path/to/file
  • Note that URI's need to be URL-encoded for embedded spaces or other special characters
  • If using password authentication, add a password in the appropriate entry field
  • If using passphrase authentication, add a passphrase in the appropriate entry field
  • Click the Tail button
  • Defaults for various ssh parameters may be set via the properties file mentioned above

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:

  • mvn.bat javadoc:javadoc

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:

  • set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_35
  • cd logviewer-common
  • mvn.bat -P generator exec:java -Dexec.args=100

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

  • 0.0.4 - Refactored and added Grizzly support
  • 0.0.3 - Added ssh support
  • 0.0.2 - Split into separate maven modules
  • 0.0.1 - Initial version

logviewer's People

Contributors

satyagraha avatar floifyarul avatar

Watchers

Arul Dhesiaseelan avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.