Quickstart Guide

This is the quickstart guide for the impatient programmer. It assumes that you already have downloaded and extracted the zip delivery, since you are reading this document. Lets get going!

  1. First you must ensure that the microlog-2.0.0-SNAPSHOT.jar file is accessible to your favorite IDE.
    1. This is done in Eclipse this way:

      Right click on the project in the "Package Explorer". Select "Build Path -> Add External Archives". You get prompted to select a zip/jar file. In this case you should select the microlog-2.0.0-SNAPSHOT-me.jar file.

    1. If you have a Maven based project read this description.
  2. Start programming!
    1. You must create a instance of a Logger for each class that you should log. Start with the main class. In our example we use a MIDlet. You could choose to have one instance for the entire application or to have one Logger/class. Both examples are presented below.

      This looks like this:

      private final static Logger log = LoggerFactory.getLogger();
      

or

private final static Logger log = LoggerFactory.getLogger(MyMidletClass.class);
  1. The 2nd step is to configure the logger. This could be done either in your application, using a property file or using dependency injection. In our case we do it in the application directly. This is of course very static, but the simplest way to get going. When you got this working, you could replace your configuration with a more flexible solution like using a property file.

    This looks like this

    public void SuperMIDlet(){
      Appender appender = new ConsoleAppender();
      log.addAppender(appender);
    }
    

    The log level is set by default to DEBUG and the default formatter is the SimpleFormatter.

  1. Do the actual logging. This looks like this:
    log.debug("MicroLog is working!");
    
  2. Compile and run your application (from your IDE).

    You should probably see your logged message.

  3. Use Properties to configure MicroLog (optional step)

    MicroLog has support for configuring using properties.

    The properties are fetched from the following sources in the specified order:

    • The JAD file
    • The Manifest file
    • A property file, e.g. microlog.properties.

    To configure using properties, just add the following to our source code:

    MidletPropertyConfigurator.configure();
    

    This configures Microlog using the default settings. It searches through


Happy logging!