I’ve been a big fan of logging for many years, and this was one of the main things I missed in BlackBerry OS. Debugging on mobile devices sometimes is a challenge – for instance, testing Location-based Services out in the field or applications with many async tasks, where debugging changes the behaviour of the application – and logging is an invaluable aid.
During these last two years I have developed a logging framework and now you can get it as Open Source.
My goal for logging4bb was to have an easy to use logging framework for BBOS. The general structure is as follows:
logging4bb registers some remote commands using BlackBerry OS Command Framework. This means that the logger is not hard bundled with other Applications and can serve as many APPs as you like.
To use logging4bb you only need to copy 5 classes into your application…
… change same parameters in the
LoggerFactory class (marked as TODO) and it works.
The logging from BlackBerry OS Applications works similar to Logging in Java SE, each class gets a logger:
// the logger private static final ILogger logger = LoggerFactory.getLogger(HelloLoggingApp.class);
and you can log as usual:
logger.debug("HelloLoggerScreen successfully initialized");
If the background app isn’t installed on the BlackBerry there’s a fallback to
sys-out logging. So it is possible to install the logger only if you need it or while testing.
For additional details, please take a look at my presentation at BlackBerry DevCon 2011 in San Francisco:
or download the pdf: Logging: Esay and Flexible
OSS as GIT repository at Bitbucket
logging4bb is hosted at Bitbucket. Why? because Bitbucket offers Unlimited Private Repositories for free.
logging4bb uses Git branches to manage different platforms in one single repository. The default master branch only has a readme file, while the other two branches have the code that is needed for each platform – please checkout the branch you need:
- dev-public is always the newest one – at the moment BB OS 7
- os6/dev-public is based on BB OS 6
Please take a look at this blog I wrote about Git and mobile development describing the structure of my GIT repositories to understand how it works.
logging4bb isn’t running out of the box because BIS is used to communicate with the logging server and you have to replace the secret connection string.
If you don’t want to use BIS, you can set
deviceside=true to use a direct socket connection, customize the transport protocol, and do it your way.
BlackBerry Forums will help if you have questions about BlackBerry Connections.
All documentation and content is licensed under Creative Commons License 3.0 (BY-NC-SA).
There are two ways to get the sources:
- Use Eclipse and download the ready-to-use Eclipse Projects, or
- Clone from GIT Repositories
Once all is installed and running you will be able to log to Lilith or SQLite on the device.
Logging to Server (Lilith Logmonitor)
Please download Lilith from Sourceforge.
Lilith is available as APP for OSX and also for Windows and Linux.
Originally Lilith was used as a LogMonitor for SLF4J / LogBack but, as you probably know, LogBack doesn’t run on BlackBerry OS. Instead logging4bb uses a trick and sends Log Messages in the same format to Lilith as this would be done using an Appender for Lilith from Java SE applications.
This is really great if you’re testing Client / Server applications – you can monitor the Logging using Lilith and watch server-logs side-by-side with logs from BlackBerry devices or Simulator.
Logging to DB (local SQLite)
logging4bb uses a local SQLite database for two use-cases:
- Storing preferences
- Storing log messages
The first time logging4bb is started, the SQLite will be created automatically and the preferences will be initialized.
Here’s an example with some log events stored into SQLite (opened with Firefox PlugIn SQLite Manager):
Problems ? Questions ? More Info ?
logging4bb requires BlackBerry OS 6+ and needs a SDCard. Documentation for the framework can be found here.
If you encounter bugs or want to request new features, please open an issue at Bitbucket here.
Thanks that I was allowed to present logging4bb as part of the OpenBBNews. I will publish additional Open Source Projects in the next months.