www.logmx.com The universal log file viewer
Last version: v2.0.2 (30 aug. 10) Analyse any log, anywhere
LogMX Manager Development
Page summary:
Useful links:

Introduction
LogMX uses Log Managers to read the bytes that will be sent to the Parser in order to extract log entries.

Each Manager is able to read bytes through a specific protocol: one will be able to read from a file on your hard disk, another one from a Web site (HTTP), another one from SCP, and so on. LogMX comes with two default Managers: a "LocalFileManager" to read files from your hard disk and a "SCPFileManager" to read files from SCP. You can also use the "SampleHTTPManager" to access logs on a web server (this Manager is an example of how to write a Manager, its Java class can be found in "managers/" directory of your LogMX distribution)

LogMX knows which Manager to use to open a resource thanks to the URL the user specified (or simply because the user chose this Manager in "Open" dialog box).

This page deals with creating your own Manager: you can implement a LogMX Manager by writing only one Java Class. Then copying this class file in a dedicated LogMX folder will allow you to use this Manager, the same way you use the default Managers.
Eclipse development environment
LogMX distribution includes an Eclipse project for developing managers.
Here is how to prepare your development environment for Eclipse:

  1. Project import
    In Eclipse, click on "File" menu, then "Import". Choose "Existing Projects into Workspace" in the dialog box and click on the "Next>" button.
    Click on the "Browse" button (in the upper right corner) and select LogMX directory before clicking the "OK" button. You can unselect "LogMX Parsers" if you don't want to write LogMX parsers (see parser dev). Then click on the "Finish" button.

     
       
    Eclipse project import


  2. Project configuration (Jar file path)
    In the "Package Explorer" view (usually on the left), right click on the new project "LogMX Managers", and select "Properties". In the new dialog box, choose "Java Build Path" (usually on the left), and go to the "Libraries" tab. Double-click the line "LOGMX_HOME/jar/logmx.jar". Click on the "Variable" button, then the "New" button. In front of "Name", type "LOGMX_HOME", then click on the "Folder" button to choose your LogMX directory (e.g. C:\Program Files\LogMX). Finally, click on "OK" buttons to go back to the "Libraries" tab.

     
       
    Eclipse project configuration: 'LOGMX_HOME' variable

  3. Project configuration (LogMX API Javadoc link)
    Always in project properties dialog box, expand the item "LOGMX_HOME/jar/logmx.jar" and double-click on "Javadoc location". Click the "Browse" button and select the "help/api" directory of your LogMX distribution. To finish, click on "OK" buttons to go back to Eclipse main window.

     
       
    Eclipse project configuration: LogMX API Javadoc link

  4. Creating your Manager
    In the "Package Explorer" view, right-click on the "src" directory of your project, and then click on the "New" > "Class" option. In the new dialog box, type a package name in front of "Package" (e.g. "my.manager"). In front of "Name", type your Manager class name (e.g. "TestManager"). In front of "Superclass", type "com.lightysoft.logmx.mgr.LogFileManager" (or you can start typing "LogFile" and use Ctrl-Space completion). Ensure option "Inherited abstract methods" is checked, and then click on the "Finish" button.

     
       
    Manager class creation with Eclipse


    You are now ready to implement your manager, see section Manager implementation for more information.

     
       
    Manager development with Eclipse (here, LogMX API javadoc helping developper)

Ant development environment
LogMX distribution includes an Ant build file for developing managers.
Here is how to develop a LogMX Manager using Ant:
  1. Creating Manager class file
    In "managers/src" directory of your LogMX distribution, create directories matching your packages name (e.g. create "my/manager/" for packages "my.manager"). Create your java class source file in your package directory (e.g. file "TestManager.java" in "my/manager/"). You are now ready to implement your manager, see section Manager implementation for more information.

  2. Compiling Manager class file
    Open a shell in the "managers" directory of your LogMX distribution, and simply type "ant" to compile in "classes" directory all managers present in "src" directory.
    Here is the list of all available targets: (use "ant -p" to get it from your shell)

    (default target) build-dev Build managers for development (no optimize, all debug symbols)
    build-prod Build managers for production (optimized, no debug symbol)
    clean Remove all generated class files
    mkoutdir Create classes output directory
Manager implementation
Writing a LogMX Java Manager consists in creating a Java class that extends the abstract class LogFileManager and implementing its abstract methods.
To get detailed information on these methods you have to implement, see our on-line javadoc or read it from your LogMX distribution (under "help/api").
For a complete example of Manager implementation, see "SampleHTTPManager.java" in directory "managers/src/sample/manager" of your LogMX distribution, or see it online: Manager class sample.
If you have any problem or question, please visit our Manager Development Forum or contact us.
Manager test
Here is how to test your Manager in LogMX:
  1. Manager compilation
    Compile your Manager to "manager/classes" (see above to compile it with Eclipse or Ant).

    NOTE: If you have several versions of Java installed, be sure to run LogMX with a Java version greater or equal to the version of the compiler you use to compile your Manager (you can run LogMX with Java 1.6 to use a Manager compiled with Java 1.5, but you cannot run it with Java 1.5 to use a Manager compiled with Java 1.6).
    To get the version you use to run LogMX, go to "Help" menu, "About" option, and click on the blue "i" icon in the left bottom corner: version is specified in front of property "java.version" in the upper table.
    To get the version you use to compile your Manager:
      • with Eclipse, right-click on your Eclipse project and select the "Properties" option. Then click on "Java compiler" in the left pane.
      • with Ant, check your JAVA_HOME environment variable. If you don't have such a variable, Ant will use the JDK directory of your PATH environment variable: type "java -version" in your shell to get this Java version.


  2. Manager installation
    In the "Tools" LogMX menu, click on "Options...". In the dialog box that appeared, go to the "Managers" tab and click on the green "+" button on the right. In the new dialog box, select your Manager class in the main tree (as you can see in this dialog box, you can add Managers included in a Jar file).
    Of course, you have to do this only once, then LogMX will use this manager if needed.

     
       
    Manager installation in LogMX


     
       
    Manager configuration in LogMX

  3. Manager test
    To test your manager, click on "File" menu, "Open" option, and select its name in the upper combo box. Then fill the form that describes the resource you want to open with your Manager.
    You can also type a URL in the upper address bar of LogMX main window (this URL must begin with your Manager protocol, like "jdbc://" for example).
    If you recompile your manager, you will have to restart LogMX to use the last version of your manager (Java stores your Manager class file in a cache for better performance). To open your log file directly at LogMX start-up, you can put its filename in the LogMX command-line arguments (or drop your log file on the LogMX executable).


Copyright © 2010 LightySoft. All rights reserved.