Determining If a Message Will Be Logged - Java Java Virtual Machine

Java examples for Java Virtual Machine:Logger

Description

Determining If a Message Will Be Logged

Demo Code

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

public class Main {
  public void m() throws Exception {
    Logger logger = Logger.getLogger("com.mycompany.MyClass");

    // Check if the message will be logged
    if (logger.isLoggable(Level.FINEST)) {
      logger.finest("my finest message");
    }/*from ww w .j a v  a 2s .com*/
  }
}

Related Tutorials