Created
June 4, 2011 03:02
-
-
Save behrangsa/1007516 to your computer and use it in GitHub Desktop.
Usage example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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