Download

Get Loom

Logging

Loom includes its own Log class that extends commons-logging with some extra features:

  • Automatic class discovery: The container class of a Loom logger is automatically discovered by examining the stack trace.
  • Automatic argument concatenation: To avoid the performance penalization when string arguments are concatenated before calling the log method, all log methods have been rewritten using varargs instead of a single string argument.

Example of Log use:

public class Foo {

	// the logging class is discovered by examining the stack trace of this call
	private static Log log = Log.getLog();

	public void doSomething() {
		// Notice the commas instead of '+' 
		log.debug("User ", userName, " has accepted ", type, ": ", id);
	}

}

It is important that your Log attribute is static and private, if possible. Log arguments will get concatenated only if the log statement gets written somewhere.