onsdag 14 juli 2010


Now it's time for the second library on this blog and the turn has come to Log4j. The log4j is a library used for logging in a Java program. The library has been highly distributed and there are many applications, both open source and proprietary that I have found using the library. The library is provided and maintained by the Apache foundation and the lib has been around for quite a while.

Log4j works with something called logging level and there are a number of levels, these are DEBUG, INFO, WARN, ERROR, FATAL. When a program that implements log4j runs it is set to log on a specific level and all messages that correspond to that and higher level (debug lowest, Fatal highest) will then be logged to the output.

Log4j is easy to use and when you have defined your logger in a class like this:
static Logger logger = Logger.getLogger(My.class);
the only thing you have to do to log something is call logger.info("Message"); This will make our program log a message on the level info.

Configuration and Appenders
What really strikes me when using this library is the powerful logging configuration that you can do after you actually have done your programming. When log4j is loaded it loads a configuration file that tells the library how you want it to log the output. To do this you add to your config something call appenders which are small applications that can take log4j output and log it to a medium, for an example there are appenders that can log to file, database, IM, email and so on.
In the configuration you are also able to configure on what level the appender should log. For a reference on how to configure the config file see the official log4j site.

In all of my Java projects Log4j is going to be sure companion due to its versatility in logging output and reconfigurability after the project has left the workshop.


log4j - Libzter Article
log4j - Official site

tisdag 13 juli 2010


As a first post I will talk a little bit about a library that I came across a couple of months ago. XStream is a java library for doing object serialization/deserialization to and from XML. I have used and played with it for some weeks and i'm impressed of what this library is capable of performing. It has never fail to serialize any of the objects that I have given it and that includes many objects that doesn't implement the serializable interface form the core java API.

The library is maintained by Codehause and is an open source library and comes with a BSD licence. I like the fact that you are able to understand and edit the xml that XStream produces of your object. Another thing that I really like with the lib is that it is so easy to use, the only thing you have to do is create your XStream object and then call the method xstremObj.toXML(myObject) to get it as an XML String and to deserialize it you call xstreamObj.fromXML(xmlString), almost to easy.

måndag 12 juli 2010

New blogg

Hi and welcome to my blog where I aim to write articles about Java and especially about libraries and frameworks. I have set a goal that I will learn more about the great tools that are available to us programmers and especially for Java.


I have also started a site with my friends called www.libzter.com where I also will post information about the libraries that i will look at. My goal with Libzter is that it should be a great site where you easily can look up any type of programming library that you are interested in and get information and examples of how to use it.

Libzter comes in the form of a Wiki so if you are a programmer and have a favorite library or even have created and distributed you own library (open source or proprietary) then write about it on Libzter and post a link back to your own site hosting the lib.

Continues work
The libraries that I will mainly focus on at the moment are going to be libraries that are licensed as open source. I hope that you as well as I will find both this blog and Libzter useful in the learning process of new programming libraries.