If all you're ever going to want to do is print a few messages to console, then System.out.println() is fine.
A proper logging system, like Log4J, adds all sorts of features that are very useful in real applications. You can direct the output to different places (console, file, network etc.). You can tell it to output only a subset of the messages, without having to recompile. You can get timestamp on each message etc.
If you're writing a small utility program for your own use, which will never expand into something more, use System.out.println(). If you're writing industrial-strength code, or a utility library for others, using a proper logging system is the professional thing to do.
Log4J is not the only one, by the way.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Joined: Sep 28, 2006
for your reply
iam scrutinize only in the performance
some bloggers have told that system.out.prrintln() will consume
to much of performance than log4j
i think log4j will consume more performance because it
Even if you use System.out.println() I would use a wrapper logging class that will later allow you to use log4j while only changing this class and not all of your apps logging methods. I don't have a good example of all the methods you should include, but something like this (as well as the methods that take an exception would be good i.e. error(message, exception))
Yeah, for normal small programs where performance or any other similar issue is never a problem, SOP's are fine, but when running a real time project, its best to use some kind of logger. log4j is great, but even the logger from the util package is better than SOPs...Another thing which intruiges me is assertions, need to use it more!