Often, you want to store all system out messages in a organized manner. Sure one can do it with log4j. But one can also implement a very simply log method which automatically adds a timestamp and the caller class name:
public static void log
(String logMsg
) {
System.
out.
println(new java.
util.
Date() +
": "
+
new Throwable().
fillInStackTrace().
getStackTrace()[1].
getClassName() +
": "
+ logMsg
);
}
There are no comments on this page. [Add comment]