|
||||||||||
PREV NEXT | FRAMES NO FRAMES |
See:
Description
Packages | |
---|---|
net.sf.microlog.core | This package contains the core classes and interfaces for Microlog. |
net.sf.microlog.core.appender | This package contains the implementation of the Appender classes for Microlog. |
net.sf.microlog.core.config | |
net.sf.microlog.core.format | This package contains classes for that format the log contents before appending it to the log. |
net.sf.microlog.core.format.command | This package contains the helper classes for the PatternFormatter. |
net.sf.microlog.midp | This package contains the MIDP specific classes for Microlog. |
net.sf.microlog.midp.appender | This package contains the implementation of the
Appender
classes for Microlog on the MIDP platform. |
net.sf.microlog.midp.bluetooth | This package contains the Bluetooth specific classes. |
net.sf.microlog.midp.file | |
net.sf.microlog.midp.wma | |
net.sf.microlog.spot | |
net.sf.microproperties | |
net.sf.microproperties.midp |
Microlog is a small logging library for Java ME (J2ME) like Log4j. It has support for logging to console, file, RecordStore, Canvas, Form, Bluetooth, a serial port (Bluetooth, IR, USB), Socket(incl SSL), UDP, Syslog, MMS, SMS, e-mail or to Amazon S3.
Quickstart Guide for Microlog ============================== 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 MicrologX.jar file is accessible to your favorite IDE. The X is the version of your Microlog jar file. The s3me.jar file must also be present. 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 MicrologX.jar file. 2. Start programming! a) 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. This looks like this: private final static Logger log = Logger.getLogger(); b) 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. c) Do the actual logging. This looks like this: log.debug("Microlog is working!"); 4) Compile and run your application (from your IDE). You should probably see your logged message. 5) 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: 1. The JAD file. 2. A property file, e.g. microlog.properties. 3. The DefaultValues class. To configure using properties, just add the following to our source code: Properties properties = new Properties(this, "/myprops.properties"); log.configure(properties); The first argument is a reference to your MIDlet and the second is the filename of your property file. There are several overloaded constructors in the Properties class. If you omit the property file, the default property file is used; microlog.properties. If your property file is not found Microlog issues a warning in your console output. Happy logging!
|
||||||||||
PREV NEXT | FRAMES NO FRAMES |