May 29, 2009

"What is Soo Special About Microlog?"

"What is So Special About Microlog?", this was the first question I got this morning when arriving to work. This was asked by one of the Java Enterprise specialists at my work. Hmmm... let me think. I was a bit paralyzed by the question, although I should not be. This is not the first time I get this question, I get this question a lot (from people not working with Java ME).

My first answer was "size!". The Log4j jar is 389kB, but Microlog is about 110 kB. But the actual jar size is not what is interesting, but the overhead that Microlog add to the jar. In normal cases it is somewhere between 30-40 kB, depending on what you decide to use. I consider this to be little overhead considering that you get two appenders with two formatters and the configuration framework with the ability to configure via properties files and/or JAD settings files. Plus you get the ability to setup your loggers in a logging hierarchy. All in all, the small size of Microlog is one of its benefits.

My second answer was "remote logging". Log4j contains some remote logging destinations, like syslog daemons and JDBC. Microlog has also support for logging to syslog daemons. This is one of my personal favorites. It is easy to setup a syslog daemon and you get the logs on the server directly. I choose not to implement JDBC support in Microlog. First of all, it makes me sick to think about setting up a JDBC server. Secondly there is not many JDBC drivers available for Java ME with CLDC. Instead I implemented support for logging to Amazon S3. It is easy to setup and you have access to very much storage for a cheap price. Right now you can upload 1 GB for $0.03. Compare this to the price of setting up a JDBC server. You cannot work for many seconds before you have used up your $0.03! It is also very pratical to log to Amazon S3. For example you log to a file, when the file gets to big or when you log above a certain level, the file is copied to the server. As far as I know this is a unique feature, this is not implemented in Log4j and I do no know any other logging library which has suport for Amazon S3. And that is not all; Microlog has support for sending an SMS/MMS or e-mail as well. Log4j has support for e-mail which is based on a simple SMTP client. Micrologs implementation is a little bit smaller and smarter. It uses the Wireless Messaging API (JSR-205) to send an e-mail. The actual assembling of the e-mail and the sending code is less than 30 lines of code. Quite impressive if you ask me, but I am a little bit biased. What do you think? These are the most important remote loggers, but there are more. Please take a look at the Microlog documentation to find out more.

The second question was "how do people do logging if they do not have Microlog?". My answer was "I am not sure, but I guess that they log to the record store or to a file". But if you choose to log to the record store, they also need to implement some kind of log viewer. The data is stored as a byte[] in the record store, which is hard to read right away.

After some further discussion with my collegue, he ask me "...then people must be very happy when the find out about Microlog?". Yes in fact they they are. At least the people that I have spooken to. Of course, sometimes people have some issues with Microlog that they do not like or like to improve. But I always try to listen to the feedback I get and improve Microlog accordingly. In fact most of the important changes are based on feedback. So please continue giving me more feedback about Microlog.

May 14, 2009

Available on Twitter

I am now available on Twitter. Use the link to the left if you want to follow me on Twitter. This is kind of a experiment for me. I am not sure whether I like Twitter or not. But at least it is worth a try.

SourceForge Community Choice Awards, Please Vote for Microlog

Every year SourceForge honors the most popular projects in the Community Choice Awards. The first nomination period for this years awards has started. Read more about in this press release. If you find Microlog useful, please nominate it by going to the SourceForge project page and press the nominate button.

Edit: For your convenience, I have provided this link to get to the right place directly.

May 13, 2009

Preparations for a Microlog Presentation @JavaForum in Sweden

It is now official; I will be talking about Microlog at the next JavaForum meeting in Gothenburg. JavaForum is the official Swedish JUG, with 3 different branches in Stockholm, Gothenburg and Malmö. The talk will be held in Gothenburg.

I am really looking forward to it. Tonight I have been preparing myself. Most of the time I have been coding. I want to improve the V2.0 branch. The goal is to stabilize the API before the presentation. My hope is that I get many downloads after the presentation. But I have also started to do a first draft of the actual presentation. I only have a 30 minute slot, so I need to carefully select the pieces that I want to be included. This is a nice little challenge. Me like it.

May 8, 2009

Android, Android, Android and Some More Android

Android is getting a lot of attention right now, both from me and a lot of other people. Recently I attended a breakfast seminar about business opportunities with Android. The author of the book "The Busy Coder's Guide to Android Development", Mark Murphy, gave an interesting presentation on the subject. After a brief technical introduction, Mark spoke about the business opportunities. As I gathered, he mostly used the classical open source business opportunities, more or less. Nevertheless the presentation was good. The most interesting part of the breakfast seminar was actually the fact that it was really crowded. I would guess that there was around 200-300 people there, which is very much for a breakfast seminar i Malmö. I meet a lot of old colleagues and all was very positive about Android.

I have just attended the "Advanced Android" course by WayEducation. It was really good and gave insight into the inner workings of the Android platform. I am looking forward to start programming Android for real, in a real project. But that is just around the corner, since it is part of our product backlog.

Last but not least I have ported some parts of Microlog to work on Android. The core is the same for Java ME and Android, but opening a file or a network connection is different. On the other hand writing the actual data is done the same way, e.g. to an OutputStream. This shows that even though Android not officially is Java, we could re-use Java code.

It will be interesting to follow what happens with Android, the platform, the community and the phones. Only time will tell.

What are you opinions/experiences with Android?

May 7, 2009

Detecting Flight Mode (Kind of) in Java ME on a Nokia Mobile

The other day I wrote an article about how to detect flight mode. But it did not cover how to solve it on a Nokia phone. On a Nokia phone, like a Sony Ericsson phone, there is no system property to detect flight mode. On the other hand, if we asume that what we really are interested in checking if the network is available or not, we have a solution on a Nokia phone. If we check this, we can make the MIDlet smart, e.g. setting it in off-line or on-line mode.

The solution is very simple:

String networkAvailable = System.getProperty("");

// Warn the user that the network is not available and off-line mode is used
// Network available => we could work as normal.

The trick here works on the Nokia S60 platform FP3, or later. I have not found out a solution on a Nokia S40 phone. Does anyone know?

May 6, 2009

Detect Airplaine/Flight Mode on Motorola and Sony Ericsson Mobile Phones in Java

Many MIDlets communicate with a server and/or connects to the Internet. If the user enables airplane/flight mode, the MIDlet should be aware of this. This way it is possible to set the MIDlet in off-line mode automatically and inform the user when trying to access the net. It is much nicer to get a dialog saying "Sorry you are in flight mode, you cannot this and that", instead of "Failed to connect to server". This article describe how to do this in Java ME (on some platforms).

There is no API that enable a Java ME developer to access the flight mode. The key here is to get a system property via the right key, no pun intended :) This is done via a call to System.getProperty("key"). The key differs from platform to platform.

On a Motorola mobile phone, with Motorola OS, this is done like this:

String airplaneMode = System.getProperty("");

// We are in flight mode
// We are not in flight mode

On a Sony Ericsson mobile phone it is a little bit different, since there is no system property to detect if we are in flight mode or not. The trick here is to use a key that detects the Radio Access Technology (RAT) used at the moment. This returns null if the radio is turned of, which it always is when in flight mode. The code looks like this:

String flightMode = System.getProperty("");

if(flightMode == null){
// We are in flight mode
// We are not in flight mode

And that is it! Pretty simple, but still powerful. I hope this trick is useful for you.

May 4, 2009

Microlog Maven Help Wanted

As you might know I am working with the new Microlog V2.0 release. From the beginning I knew that I needed to do some re-factoring of the code and add some new functionality. The re-factoring was fairly easy, but the logging hierarchy and the new configuration has taken more time than expected. What is bothering me right now is the fact that there is a lot of other work to do. The most work is Maven related. I am not very fluent in speaking Maven, so it is a huge step for me. But coming to think about it, I have found out that I could use the power of open source development; getting help from others. I have therefore posted a "Maven Help Wanted" in the Microlog forums. But I might ask you, the blog readers, about help as well. If you are interested, please contact me and be a part of the Microlog project. For your convenience I have pasted the original post here. Please join the discussion in the Microlog forums;


I am working hard on the Microlog V2.0 release. But I have found out that I need help with some Maven related tasks.
Could you PLEASE help me out?

I feel that I need to focus on the coding work and I am not very good with Maven.
If you are good at Maven it should be easy to do the tasks that I suggests.
So help is really, really very much appreciated!

Here comes a description of the tasks that I feel that we need to perform.

===== Maven Tasks =====

* Two distributables; one binary and one source code distribution.
* Get the deploy task to work. The Maven repository is not up-to-date.
* Enable the Eclipse Maven plug-in.
* Write a "Developer Getting Started Guide". How to check out, install Maven, use Maven to create Eclipse projects, etc.
* Include the Android project in the Maven build.
* Get the testing and code coverage to work.

A more detailed description of the task "Two Distributables":

* There binary distribution needs to the broken down to small jars. I suggest the following jars:
- microlog-core.jar
- microlog-common.jar
- microlog-midp.jar
- microlog-spot.jar
- microlog-android.jar

Note: these correspond to the new sub-packages found in Microlog V2.0

* The binary distribution should have a directory structure like this:

/jars - all the jars
/bin - all the servers as binary jars or even better as .exe files.
/docs - all the docs
/docs/javadocs - all the javadocs

* The source code distribution should have all the projects packaged in their own directory, like this

... etc

I could have missed out on something, please comment on my suggestion. If you want to perform a task, please inform the rest of us.
I will create tasks in the SourceForge task list, so we can keep track on the progress of our work.

Any takers?