lunedì 29 novembre 1999

J2ME logging library: Microlog

On device debug has been always a headache source for every j2me developers. When you run the application on an emulator you can always use the System.out.prinln instruction (remember to use a method that make possible leave out this log code when you deploy your application) and see the result in the console windows but the same result is not easy reachble when the midlet is running in a real device.


Personally I've created my simple logging structure that write information in a specific screen of the application that you can view clicking on some digits of the phone keyboard.


Two days ago I received a message from a Linkedin group that contained a link to this log library called Microlog, an open source project of a j2me logging library.


This library is build thinking at Log4j and supports 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


The following are the key features:




  • Easy to setup. Configuration via the application descriptor, dependency injection or a property file.

  • Similar to Log4j, but built from scratch.

  • Small

  • Fast

  • Many different Appenders

    • ConsoleAppender - Appends to the console, e.g. System.out.

    • RecordStoreAppender - Appends to the RecordStore.

    • FileAppender - Appends to a file using a FileConnection.

    • CanvasAppender - Appends to a Canvas.

    • FormAppender - Appends to a Form.

    • BluetoothSerialAppender - Appends to a Bluetooth serial connection (btspp).

    • SerialAppender - Appends to a serial port (CommConnection).

    • SmsAppender - Appends to a cyclic buffer and send the buffer as an SMS.

    • MmsAppender (for MMS and/or e-mail) - Appends to a cyclic buffer and send the buffer as an SMS.

    • DatagramAppender - Appends to a datagram and send it using UDP.

    • SyslogAppender - Appends to syslog server.

    • SocketAppender - Appends to a socket connection (also SSL).

    • S3FileAppender - Appends to a file, as in the FileAppender, and stores the file on Amazon S3.

    • S3BufferAppender - Appends to a cyclic buffer and stores it as a file on Amazon S3.





  • Different Formatters for different needs

    • SimpleFormatter - Simple, fast and very small.

    • ConfigurableFormatter - A simple, but yet configurable formatter.

    • PatternFormatter - Decide exactly how you want to format your log messages. Inspired by the PatternLayout found in Log4j.



  • High quality. We use use these tools to ensure that Microlog has high quality:

    • Unit tests (CLDCUnit combined with JUnit tests)

    • Code checks (FindBugs & Lint4j)





 


  As they say, the library can be adpated to different development stages:




  1. Early development stage Use the ConsoleAppender and/or the RecordStoreAppender. Use the SimpleFormatter to start with. This makes it possible to run in the emulator and on the target device without any problems.

  2. Main development stage Use the BluetoothSerialAppender to easily transfer the log directly to your PC. The PatternFormatter should be used to create better logging output, e.g. the thread name.

  3. Field test by the developers Use the SyslogAppender class to log directly to a syslog server maintained by your team. The syslog daemon could be used to forward the logging messages, for example by sending e-mail.

  4. Beta/Early access tests Use the MMSAppender to send logs when something critical has happened, e.g. when a FATAL or ERROR message has been logged. This could be sent directly to your bug reporting system and/or some mailing list for your development team. Or you could use the S3FileAppender to log directly into your Amazon S3 account.



Again, any comments from people using it is welcome.

Nessun commento:

Posta un commento