Saturday, September 22, 2007

Log4J from scratch

Log4J from scratch

Classes:
  • Logger
  • Categories
  • Priorities
    • Fatal
    • Error
    • Warn
    • Info
    • Debug
  • Appenders
  • Layouts

xml configured file has higher priority than properties file (log4j.xml is with highest priority than log4j.properties). Sample log4j.xml


The test class:

import org.apache.log4j.Logger;

public class Main {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(Main.class);

public static void main(String[] args) {
if (logger.isDebugEnabled()) {
logger.debug("main(String[]) - start");
}

if (logger.isDebugEnabled()) {
logger.debug("main(String[]) - TADA Info - args=" + args);
}

logger.error("main(String[]) - Tada Severe", null);

if (logger.isEnabledFor(org.apache.log4j.Level.FATAL)) {
logger.fatal("main(String[]) - rsere", null);
}

logger.warn("main(String[]) - asfas", null);

if (logger.isEnabledFor(org.apache.log4j.Level.WARN)) {
logger.warn("main(String[]) - asfasf", null);
}

if (logger.isInfoEnabled()) {
logger.info("main(String[]) - adfasdfsdf");
}

if (logger.isDebugEnabled()) {
logger.debug("main(String[]) - end");
}
}

}

Friday, August 24, 2007

Bug with Google Documents



Today when I try to complete my daily journal of problems, in my browser I saw the 'bad news' from Google Docs :) which is a prove for me that there are no perfect solutions. That makes me happy because I work as a software engineer and every day I must to solve many weird 'technical' problems.

Thursday, June 14, 2007

Online AJAX editor from Google

Google Mashup Editor seems to be an interesting solution for code a few dhtml files.
After many amazing online applications from Google let's see what will happen in the future ... desktop applications will die and will be forgotten or not :) ?

Tuesday, June 5, 2007

EJB3Unit

One day, when God was looking over his creatures, he noticed a boy named Sadhu whose humor
and cleverness pleased him. God felt generous that day and granted Sadhu three wishes. Sadhu asked
for three reincarnations--one as a ladybug, one as an elephant, and the last as a cow. Surprised by
these wishes, God asked Sadhu to explain himself. The boy replied, "I want to be a ladybug so that
everyone in the world will admire me for my beauty and forgive the fact that I do no work. Being an
elephant will be fun because I can gobble down enormous amounts of food without being ridiculed. I
will like being a cow the best because I will be loved by all and useful to mankind." God was charmed
by these answers and allowed Sadhu to live through the three incarnations. He then made Sadhu a
morning star for his service to mankind as a cow.
EJB too has lived through three incarnations. When it was first released, the industry was dazzled
by its innovations. But like the ladybug, EJB 1 had limited functionality. The second EJB
incarnation was just about as heavy as the largest of our beloved pachyderms. The brave souls who
could not do without its elephant-power had to tame the awesome complexity of EJB 2. And finally,
in its third incarnation, EJB has become much more useful to the huddled masses, just like the gentle
bovine that is sacred for Hindus and respected as a mother whose milk feeds us all..

(EJB 3 in action -Debu Panda, Reza Rahman, Derek Lane - 2006 Manning Publications)
After many POJO frameworks appears EJB 3.0 tends to simplify things while other early technologies like TopLink tends to fall hard ...an interesting framework for ejb3 unit testing is EJB3Unit

Sunday, June 3, 2007

Guice - dependency injection container from Google

Things that have a common quality ever quickly seek their kind.(Marcus Aurelius, Meditations, ix. 9.)
While I was reading this article http://code.google.com/p/google-guice/wiki/SpringComparison the idea of testability and improvement of quality that may result from better design of software was bearing in my mind.
In the other hand "Quality is the eye of the beholder" and many companies still produce software with poor quality but is managerial decision related to reduce the costs of the production
To keep the balance between quality and productivity we must adapt the changes and often to forgot the practices that we know and start over and over again with the new techniques.
In many situations the past must be forgotten only the future matters, but how will be the future in the software world ? Since 1997 Java as a programming language changed a lot since then many other languages & frameworks came to front and others tends to be forgotten.
In one day maybe the software will become an insignificant part of every device that will be around us...

Another interesting article about inversion of dependency is the Fowler's article