Tuesday, June 29, 2010

log 4j

Call me "Loser" for posting this easy logger.

But it can be an asset for you guys like green horns ...
I don't mean you are a cow .... I refer to newbies .... :)

Well, log 4j is most commonly used logger for logging in Java based system.
Full name can be apache log4 j.
Some foolish and dull companies sometimes put this in requirements.
:) funniest joke in Java world ... It is just 3 lines of codes or may be 2.5 lines to read and understand.

first download the log4j.jar from web.
And import it.
write a line of code

public static Logger logger = Logger.getLogger(ClassName.class);

And configure your log4j properties.
Very very easy... Super easy and chicken feets....

Normally we use

logger.debug for debgugging
logger.error for erro
and logger.info for information

There is some important reason behind. If somebody asks you in interview, juz says System.out can make you out from the system ... Juz kidding... it is so bad ... uses a lot of memory and sometimes, it can lead the system hang or markedly delay in process. Log4j is better but not the best.

Try not to use a lot of printing things.
Use properly in testing phase and try to clear out if you are sure it is not necessary after the testing phase.

Try it out yourself ....
And never ever use printline so much ....

It can save your life and live long as a happy developer ....

Don't call me "loser" .... if you don't understand clearly what I wanna point out.

The Easiest way to learn is learning by yourself .... If we teach something to you, you will not be learnt so much ... Our brian is so selfish ... It only memorizes deeply what it learnt itself....

Good Luck, mate ...!!!

Zero ..

Bro ... I will catch up soon ... 3 posts in one day ... :P

No comments: