Skip to content

Instantly share code, notes, and snippets.

@behrangsa
Created June 4, 2011 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save behrangsa/1007516 to your computer and use it in GitHub Desktop.
Save behrangsa/1007516 to your computer and use it in GitHub Desktop.
Usage example
import java.util.Calendar;
public class Main {
private static final Logger LOG = new Logger();
public static void main(String[] args) {
LOG.setLevel(Level.WARNING);
// This will be logged as the log level is WARNING
LOG.log(Level.WARNING, { => "Simple log message"});
// A complex log message that will be logged
LOG.log(Level.WARNING, { =>
Calendar cal = Calendar.getInstance();
StringBuilder msg = new StringBuilder();
msg.append("Current calendar object is: ").append(cal).append("\n");
msg.toString()
});
// A complex log message that won't be logged
LOG.log(Level.INFO, { =>
StringBuilder str = new StringBuilder();
for (int i = 0; i < 10; i++) {
str.append(i).append(" ");
}
str.toString()
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment