Minimizing the Impact of Logging Code - Java Java Virtual Machine

Java examples for Java Virtual Machine:Logger

Description

Minimizing the Impact of Logging Code

Demo Code

import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
  public static void main(String[] args) throws Exception {
    int count = 123;
    Logger logger = Logger.getLogger("com.mycompany.MyClass");
    logger.finest("count: " + count);
    if (logger.isLoggable(Level.FINEST)) {
      logger.finest("count: " + count);
    }/*www . j  av  a  2  s .  co  m*/
  }
}

Related Tutorials